This is an automated email from the ASF dual-hosted git repository. blankensteiner pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pulsar-dotpulsar.git
commit f7639e6f18d7f846b04e1992cf5dfcb102d73f1f Author: SeĢrgio Silveira <[email protected]> AuthorDate: Tue Mar 31 16:37:58 2020 +0200 code review change requests fixed style rules accordingly --- DotPulsar.sln.DotSettings | 6 +- tests/DotPulsar.Tests/Internal/Crc32CTests.cs | 24 +---- .../Extensions/ReadOnlySequenceExtensionsTests.cs | 103 ++++----------------- .../Internal/SequenceBuilderTests.cs | 14 ++- 4 files changed, 36 insertions(+), 111 deletions(-) diff --git a/DotPulsar.sln.DotSettings b/DotPulsar.sln.DotSettings index 7bfa62b..5899e9c 100644 --- a/DotPulsar.sln.DotSettings +++ b/DotPulsar.sln.DotSettings @@ -33,10 +33,10 @@ <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_EXISTING_EMBEDDED_ARRANGEMENT/@EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_EXISTING_EMBEDDED_BLOCK_ARRANGEMENT/@EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_EXISTING_EXPR_MEMBER_ARRANGEMENT/@EntryValue">False</s:Boolean> - <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_EXISTING_INITIALIZER_ARRANGEMENT/@EntryValue">True</s:Boolean> + <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_EXISTING_INITIALIZER_ARRANGEMENT/@EntryValue">False</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/KEEP_EXISTING_SWITCH_EXPRESSION_ARRANGEMENT/@EntryValue">False</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/LINE_FEED_AT_FILE_END/@EntryValue">True</s:Boolean> - <s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/MAX_ARRAY_INITIALIZER_ELEMENTS_ON_LINE/@EntryValue">4</s:Int64> + <s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/MAX_ARRAY_INITIALIZER_ELEMENTS_ON_LINE/@EntryValue">10</s:Int64> <s:Int64 x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/MAX_INITIALIZER_ELEMENTS_ON_LINE/@EntryValue">4</s:Int64> <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_ACCESSORHOLDER_ATTRIBUTE_ON_SAME_LINE_EX/@EntryValue">NEVER</s:String> <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_EXPR_ACCESSOR_ON_SINGLE_LINE/@EntryValue">ALWAYS</s:String> @@ -47,7 +47,7 @@ <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_EMBEDDED_STATEMENT_ON_SAME_LINE/@EntryValue">NEVER</s:String> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/PLACE_SIMPLE_INITIALIZER_ON_SINGLE_LINE/@EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/SPACE_WITHIN_SINGLE_LINE_ARRAY_INITIALIZER_BRACES/@EntryValue">True</s:Boolean> - <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_ARRAY_INITIALIZER_STYLE/@EntryValue">CHOP_IF_LONG</s:String> + <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_ARRAY_INITIALIZER_STYLE/@EntryValue">WRAP_IF_LONG</s:String> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_BEFORE_ARROW_WITH_EXPRESSIONS/@EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_BEFORE_EXTENDS_COLON/@EntryValue">True</s:Boolean> <s:Boolean x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/WRAP_BEFORE_FIRST_TYPE_PARAMETER_CONSTRAINT/@EntryValue">True</s:Boolean> diff --git a/tests/DotPulsar.Tests/Internal/Crc32CTests.cs b/tests/DotPulsar.Tests/Internal/Crc32CTests.cs index e1a62dd..b3d5fd5 100644 --- a/tests/DotPulsar.Tests/Internal/Crc32CTests.cs +++ b/tests/DotPulsar.Tests/Internal/Crc32CTests.cs @@ -23,12 +23,7 @@ namespace DotPulsar.Tests.Internal public void Calculate_GivenSequenceWithSingleSegment_ShouldReturnExpectedChecksum() { //Arrange - var segment = new byte[] - { - 0x10, 0x01, 0x18, 0xc9, - 0xf8, 0x86, 0x94, 0xeb, - 0x2c - }; + var segment = new byte[] { 0x10, 0x01, 0x18, 0xc9, 0xf8, 0x86, 0x94, 0xeb, 0x2c }; var sequence = new SequenceBuilder<byte>().Append(segment).Build(); @@ -46,21 +41,12 @@ namespace DotPulsar.Tests.Internal //Arrange var s1 = new byte[] { - 0x0a, 0x0f, 0x73, 0x74, - 0x61, 0x6e, 0x64, 0x61, - 0x6c, 0x6f, 0x6e, 0x65, - 0x2d, 0x33, 0x30, 0x2d, - 0x35, 0x10, 0x00, 0x18, - 0xc7, 0xee, 0xa3, 0x93, - 0xeb, 0x2c, 0x58, 0x01 + 0x0a, 0x0f, 0x73, 0x74, 0x61, 0x6e, 0x64, 0x61, 0x6c, 0x6f, + 0x6e, 0x65, 0x2d, 0x33, 0x30, 0x2d, 0x35, 0x10, 0x00, 0x18, + 0xc7, 0xee, 0xa3, 0x93, 0xeb, 0x2c, 0x58, 0x01 }; - var s2 = new byte[] - { - 0x10, 0x01, 0x18, 0xc9, - 0xf8, 0x86, 0x94, 0xeb, - 0x2c - }; + var s2 = new byte[] { 0x10, 0x01, 0x18, 0xc9, 0xf8, 0x86, 0x94, 0xeb, 0x2c }; var sequence = new SequenceBuilder<byte>().Append(s1).Append(s2).Build(); diff --git a/tests/DotPulsar.Tests/Internal/Extensions/ReadOnlySequenceExtensionsTests.cs b/tests/DotPulsar.Tests/Internal/Extensions/ReadOnlySequenceExtensionsTests.cs index fbdeebb..91f2c7b 100644 --- a/tests/DotPulsar.Tests/Internal/Extensions/ReadOnlySequenceExtensionsTests.cs +++ b/tests/DotPulsar.Tests/Internal/Extensions/ReadOnlySequenceExtensionsTests.cs @@ -24,16 +24,10 @@ namespace DotPulsar.Tests.Internal.Extensions public void StartsWith_GivenToShortSequenceWithSingleSegment_ShouldReturnFalse() { //Arrange - var sequence = new SequenceBuilder<byte>().Append(new byte[] - { - 0x00 - }).Build(); + var sequence = new SequenceBuilder<byte>().Append(new byte[] { 0x00 }).Build(); //Act - var actual = sequence.StartsWith(new byte[] - { - 0x00, 0x01 - }); + var actual = sequence.StartsWith(new byte[] { 0x00, 0x01 }); //Assert Assert.False(actual); @@ -43,16 +37,10 @@ namespace DotPulsar.Tests.Internal.Extensions public void StartsWith_GivenSequenceWithSingleSegment_ShouldReturnFalse() { //Arrange - var sequence = new SequenceBuilder<byte>().Append(new byte[] - { - 0x00, 0x02, 0x01 - }).Build(); + var sequence = new SequenceBuilder<byte>().Append(new byte[] { 0x00, 0x02, 0x01 }).Build(); //Act - var actual = sequence.StartsWith(new byte[] - { - 0x00, 0x01 - }); + var actual = sequence.StartsWith(new byte[] { 0x00, 0x01 }); //Assert Assert.False(actual); @@ -62,16 +50,10 @@ namespace DotPulsar.Tests.Internal.Extensions public void StartsWith_GivenSequenceWithSingleSegment_ShouldReturnTrue() { //Arrange - var sequence = new SequenceBuilder<byte>().Append(new byte[] - { - 0x00, 0x01, 0x02 - }).Build(); + var sequence = new SequenceBuilder<byte>().Append(new byte[] { 0x00, 0x01, 0x02 }).Build(); //Act - var actual = sequence.StartsWith(new byte[] - { - 0x00, 0x01 - }); + var actual = sequence.StartsWith(new byte[] { 0x00, 0x01 }); //Assert Assert.True(actual); @@ -81,19 +63,10 @@ namespace DotPulsar.Tests.Internal.Extensions public void StartsWith_GivenToShortSequenceWithMultipleSegments_ShouldReturnFalse() { //Arrange - var sequence = new SequenceBuilder<byte>().Append(new byte[] - { - 0x00, 0x01 - }).Append(new byte[] - { - 0x02 - }).Build(); + var sequence = new SequenceBuilder<byte>().Append(new byte[] { 0x00, 0x01 }).Append(new byte[] { 0x02 }).Build(); //Act - var actual = sequence.StartsWith(new byte[] - { - 0x00, 0x01, 0x02, 0x03 - }); + var actual = sequence.StartsWith(new byte[] { 0x00, 0x01, 0x02, 0x03 }); //Assert Assert.False(actual); @@ -103,19 +76,10 @@ namespace DotPulsar.Tests.Internal.Extensions public void StartsWith_GivenSequenceWithMultipleSegments_ShouldReturnFalse() { //Arrange - var sequence = new SequenceBuilder<byte>().Append(new byte[] - { - 0x00, 0x02 - }).Append(new byte[] - { - 0x01, 0x03 - }).Build(); + var sequence = new SequenceBuilder<byte>().Append(new byte[] { 0x00, 0x02 }).Append(new byte[] { 0x01, 0x03 }).Build(); //Act - var actual = sequence.StartsWith(new byte[] - { - 0x00, 0x01, 0x02 - }); + var actual = sequence.StartsWith(new byte[] { 0x00, 0x01, 0x02 }); //Assert Assert.False(actual); @@ -125,19 +89,10 @@ namespace DotPulsar.Tests.Internal.Extensions public void StartsWith_GivenSequenceWithMultipleSegments_ShouldReturnTrue() { //Arrange - var sequence = new SequenceBuilder<byte>().Append(new byte[] - { - 0x00, 0x01 - }).Append(new byte[] - { - 0x02, 0x03 - }).Build(); + var sequence = new SequenceBuilder<byte>().Append(new byte[] { 0x00, 0x01 }).Append(new byte[] { 0x02, 0x03 }).Build(); //Act - var actual = sequence.StartsWith(new byte[] - { - 0x00, 0x01, 0x02 - }); + var actual = sequence.StartsWith(new byte[] { 0x00, 0x01, 0x02 }); //Assert Assert.True(actual); @@ -147,10 +102,7 @@ namespace DotPulsar.Tests.Internal.Extensions public void ReadUInt32_GivenSequenceWithSingleSegment_ShouldGiveExceptedResult() { //Arrange - var sequence = new SequenceBuilder<byte>().Append(new byte[] - { - 0x00, 0x01, 0x02, 0x03 - }).Build(); + var sequence = new SequenceBuilder<byte>().Append(new byte[] { 0x00, 0x01, 0x02, 0x03 }).Build(); //Act var actual = sequence.ReadUInt32(0, true); @@ -164,11 +116,7 @@ namespace DotPulsar.Tests.Internal.Extensions public void ReadUInt32_GivenSequenceWithSingleSegmentAndNonZeroStart_ShouldGiveExceptedResult() { //Arrange - var sequence = new SequenceBuilder<byte>().Append(new byte[] - { - 0x09, 0x00, 0x01, 0x02, - 0x03 - }).Build(); + var sequence = new SequenceBuilder<byte>().Append(new byte[] { 0x09, 0x00, 0x01, 0x02, 0x03 }).Build(); //Act var actual = sequence.ReadUInt32(1, true); @@ -182,13 +130,7 @@ namespace DotPulsar.Tests.Internal.Extensions public void ReadUInt32_GivenSequenceWithMultipleSegments_ShouldGiveExceptedResult() { //Arrange - var sequence = new SequenceBuilder<byte>().Append(new byte[] - { - 0x00, 0x01 - }).Append(new byte[] - { - 0x02, 0x03 - }).Build(); + var sequence = new SequenceBuilder<byte>().Append(new byte[] { 0x00, 0x01 }).Append(new byte[] { 0x02, 0x03 }).Build(); //Act var actual = sequence.ReadUInt32(0, true); @@ -203,18 +145,9 @@ namespace DotPulsar.Tests.Internal.Extensions { //Arrange var sequence = new SequenceBuilder<byte>() - .Append(new byte[] - { - 0x09, 0x09, 0x09 - }) - .Append(new byte[] - { - 0x09, 0x00, 0x01 - }) - .Append(new byte[] - { - 0x02, 0x03 - }).Build(); + .Append(new byte[] { 0x09, 0x09, 0x09 }) + .Append(new byte[] { 0x09, 0x00, 0x01 }) + .Append(new byte[] { 0x02, 0x03 }).Build(); //Act var actual = sequence.ReadUInt32(4, true); diff --git a/tests/DotPulsar.Tests/Internal/SequenceBuilderTests.cs b/tests/DotPulsar.Tests/Internal/SequenceBuilderTests.cs index 878f241..60a8e86 100644 --- a/tests/DotPulsar.Tests/Internal/SequenceBuilderTests.cs +++ b/tests/DotPulsar.Tests/Internal/SequenceBuilderTests.cs @@ -28,8 +28,10 @@ namespace DotPulsar.Tests.Internal var b = new byte[] { 0x04, 0x05, 0x06, 0x07, 0x08 }; var c = new byte[] { 0x09 }; + var builder = new SequenceBuilder<byte>().Append(a).Append(b).Append(c); + //Act - var sequence = new SequenceBuilder<byte>().Append(a).Append(b).Append(c).Build(); + var sequence = builder.Build(); //Assert var array = sequence.ToArray(); @@ -49,9 +51,10 @@ namespace DotPulsar.Tests.Internal var e = new byte[] { 0x08, 0x09 }; var seq = new SequenceBuilder<byte>().Append(b).Append(c).Append(d).Build(); + var builder = new SequenceBuilder<byte>().Append(a).Append(seq).Append(e); //Act - var sequence = new SequenceBuilder<byte>().Append(a).Append(seq).Append(e).Build(); + var sequence = builder.Build(); //Assert var array = sequence.ToArray(); @@ -68,8 +71,10 @@ namespace DotPulsar.Tests.Internal var b = new byte[] { 0x04, 0x05, 0x06, 0x07, 0x08 }; var c = new byte[] { 0x09 }; + var builder = new SequenceBuilder<byte>().Prepend(c).Prepend(b).Prepend(a); + //Act - var sequence = new SequenceBuilder<byte>().Prepend(c).Prepend(b).Prepend(a).Build(); + var sequence = builder.Build(); //Assert var array = sequence.ToArray(); @@ -89,9 +94,10 @@ namespace DotPulsar.Tests.Internal var e = new byte[] { 0x08, 0x09 }; var seq = new SequenceBuilder<byte>().Prepend(d).Prepend(c).Prepend(b).Build(); + var builder = new SequenceBuilder<byte>().Prepend(e).Prepend(seq).Prepend(a); //Act - var sequence = new SequenceBuilder<byte>().Prepend(e).Prepend(seq).Prepend(a).Build(); + var sequence = builder.Build(); //Assert var array = sequence.ToArray();
