From fbf0cf838da5f9b0919d86f6e81b6548092fc6ed Mon Sep 17 00:00:00 2001 From: Alexander Grechishkin Date: Thu, 15 Feb 2018 19:30:12 +0200 Subject: [PATCH 1/6] update .gitignore for VS2017 --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c3c1f2d..7b51b46 100644 --- a/.gitignore +++ b/.gitignore @@ -30,6 +30,7 @@ obj/ [Rr]elease*/ Ankh.NoLoad .nuget/nuget.exe +.vs/ #Tooling _ReSharper*/ From d10d4e016422238ce406f066201e0c264d77301e Mon Sep 17 00:00:00 2001 From: Alexander Grechishkin Date: Sat, 24 Mar 2018 13:47:29 +0200 Subject: [PATCH 2/6] fix disposing issues and incorrect work in netcore2.0 --- src/protobuf-net-data/ProtoDataReader.cs | 5 +- src/protobuf-net-data/ProtoDataStream.cs | 51 +++--- .../AfterCloseTests.cs | 167 ++++++++++++++++- .../BackwardsCompatibilityTests.cs | 9 +- .../DataSerializerTests.cs | 19 +- .../MultipleDataTableTests.cs | 135 +++++++------- ...otoBufDataReaderTests.TheGetBytesMethod.cs | 6 +- ...otoBufDataReaderTests.TheGetCharsMethod.cs | 6 +- ...toBufDataReaderTests.TheGetDataTypeName.cs | 2 +- ...rotoBufDataReaderTests.TheGetNameMethod.cs | 2 +- ...DataReaderTests.TheGetSchemaTableMethod.cs | 2 +- ...toBufDataReaderTests.TheGetStringMethod.cs | 2 +- ...otoBufDataReaderTests.TheGetValueMethod.cs | 2 +- ...toBufDataReaderTests.TheGetValuesMethod.cs | 4 +- ...oBufDataReaderTests.TheNextResultMethod.cs | 2 +- .../ProtoDataStreamTests.cs | 172 ++++++++++++++++-- .../protobuf-net-data.Tests.csproj | 39 +++- 17 files changed, 481 insertions(+), 144 deletions(-) diff --git a/src/protobuf-net-data/ProtoDataReader.cs b/src/protobuf-net-data/ProtoDataReader.cs index 4d98f4b..1c49787 100644 --- a/src/protobuf-net-data/ProtoDataReader.cs +++ b/src/protobuf-net-data/ProtoDataReader.cs @@ -92,7 +92,7 @@ public int Depth } } - public bool IsClosed { get; private set; } + public bool IsClosed => this.disposed; /// /// Gets the number of rows changed, inserted, or deleted. @@ -341,8 +341,7 @@ public bool IsDBNull(int i) public void Close() { - stream.Close(); - IsClosed = true; + this.Dispose(); } public bool NextResult() diff --git a/src/protobuf-net-data/ProtoDataStream.cs b/src/protobuf-net-data/ProtoDataStream.cs index d93a2ca..e5d9457 100644 --- a/src/protobuf-net-data/ProtoDataStream.cs +++ b/src/protobuf-net-data/ProtoDataStream.cs @@ -30,17 +30,19 @@ namespace ProtoBuf.Data /// Not guaranteed to be thread safe. public class ProtoDataStream : Stream { + private const int ProtoWriterBufferSize = 1024; + /// /// Buffer size. /// - public const int DefaultBufferSize = 128 * 1024; + public const int DefaultBufferSize = 128 * ProtoWriterBufferSize; private readonly ProtoDataWriterOptions options; private readonly ProtoDataColumnFactory columnFactory; private IDataReader reader; private ProtoWriter writer; - private Stream bufferStream; + private CircularStream bufferStream; private bool disposed; private int resultIndex; private bool isHeaderWritten; @@ -127,8 +129,8 @@ public ProtoDataStream(IDataReader reader, int bufferSize = DefaultBufferSize) /// You should not need to change this unless you have exceptionally /// large rows or an exceptionally high number of columns. public ProtoDataStream( - IDataReader reader, - ProtoDataWriterOptions options, + IDataReader reader, + ProtoDataWriterOptions options, int bufferSize = DefaultBufferSize) { if (reader == null) @@ -157,7 +159,7 @@ public ProtoDataStream( public override bool CanRead { - get { return true; } + get { return !disposed; } } public override bool CanSeek @@ -179,6 +181,10 @@ public override long Position { get { + if (readerIsClosed) + { + throw new InvalidOperationException("Reader is closed."); + } return bufferStream.Position; } @@ -222,33 +228,20 @@ public override void Write(byte[] buffer, int offset, int count) throw new InvalidOperationException("This is a stream for reading serialized bytes. Writing is not supported."); } - public override void Close() - { - readerIsClosed = true; - if (reader != null) - { - reader.Close(); - } - } - protected override void Dispose(bool disposing) { if (!disposed) { if (disposing) { + CloseReader(); + if (writer != null) { ((IDisposable)writer).Dispose(); writer = null; } - if (reader != null) - { - reader.Dispose(); - reader = null; - } - if (bufferStream != null) { bufferStream.Dispose(); @@ -260,6 +253,17 @@ protected override void Dispose(bool disposing) } } + private void CloseReader() + { + if (this.reader != null) + { + this.reader.Dispose(); + this.reader = null; + } + + this.readerIsClosed = true; + } + private void WriteHeaderIfRequired() { if (isHeaderWritten) @@ -285,7 +289,9 @@ private void FillBuffer(int requestedLength) WriteHeaderIfRequired(); // write the rows - while (bufferStream.Length < requestedLength) + while (this.bufferStream.Length < requestedLength && + // protobuf-net not always return 1024 byte, so buffer can owerflow + bufferStream.Capacity - bufferStream.Length >= ProtoWriterBufferSize) { // NB protobuf-net only flushes every 1024 bytes. So // it might take a few iterations for bufferStream.Length to @@ -308,8 +314,9 @@ private void FillBuffer(int requestedLength) else { // All done, no more results. + // little optimization writer.Close(); - Close(); + CloseReader(); } break; diff --git a/test/protobuf-net-data.Tests/AfterCloseTests.cs b/test/protobuf-net-data.Tests/AfterCloseTests.cs index 8094728..d30b9cd 100644 --- a/test/protobuf-net-data.Tests/AfterCloseTests.cs +++ b/test/protobuf-net-data.Tests/AfterCloseTests.cs @@ -15,7 +15,7 @@ using System; using System.Data; using System.IO; -using SharpTestsEx; +using System.Reflection; using Xunit; namespace ProtoBuf.Data.Tests @@ -26,7 +26,7 @@ public class When_the_reader_has_been_closed : IDisposable { private IDataReader reader; private MemoryStream stream; - + public When_the_reader_has_been_closed() { stream = new MemoryStream(); @@ -51,7 +51,7 @@ public void Dispose() [Fact] public void IsClosed_should_be_set() { - reader.IsClosed.Should().Be.True(); + Assert.True(reader.IsClosed); } [Fact] @@ -135,6 +135,167 @@ public void Should_throw_an_exception_if_you_try_to_get_a_columns_data_type_name { Assert.Throws(() => reader.GetDataTypeName(0)); } + [Fact] + public void Should_clean_underlaying_stream() + { + var field = this.reader.GetType().GetField("stream", BindingFlags.NonPublic | BindingFlags.Instance); + Assert.NotNull(field); + + var streamValue = field.GetValue(this.reader); + Assert.Null(streamValue); + } + + [Fact] + public void Should_clean_underlaying_reader() + { + var field = this.reader.GetType().GetField("reader", BindingFlags.NonPublic | BindingFlags.Instance); + Assert.NotNull(field); + + var readerValue = field.GetValue(this.reader); + Assert.Null(readerValue); + } + + [Fact] + public void Should_clean_underlaying_dataTable() + { + var field = this.reader.GetType().GetField("dataTable", BindingFlags.NonPublic | BindingFlags.Instance); + Assert.NotNull(field); + + var dataTableValue = field.GetValue(this.reader); + Assert.Null(dataTableValue); + } + } + + public class When_the_reader_has_been_disposed + { + private WeakReference streamRef; + private WeakReference readerRef; + + public When_the_reader_has_been_disposed() + { + var stream = new MemoryStream(); + using (var table = TestData.SmallDataTable()) + using (var tableReader = table.CreateDataReader()) + { + DataSerializer.Serialize(stream, tableReader); + } + + stream.Seek(0, SeekOrigin.Begin); + var reader = DataSerializer.Deserialize(stream); + + streamRef = new WeakReference(stream); + readerRef = new WeakReference(reader); + + reader.Dispose(); + } + + [Fact] + public void Reader_should_collected_by_GC() + { + GC.Collect(); + GC.WaitForPendingFinalizers(); + + Assert.False(this.readerRef.IsAlive); + Assert.False(this.streamRef.IsAlive); + } + } + + public class When_the_proto_stream_has_been_closed + { + ProtoDataStream protoStream; + + public When_the_proto_stream_has_been_closed() + { + using (var table = TestData.SmallDataTable()) + using (var tableReader = table.CreateDataReader()) + { + protoStream = new ProtoDataStream(tableReader); + } + + protoStream.Close(); + } + + [Fact] + public void CanRead_should_be_false() + { + Assert.False(protoStream.CanRead); + } + + [Fact] + public void Should_not_throw_an_exception_if_you_try_to_close_it_twice() + { + protoStream.Close(); + protoStream.Close(); + } + + [Fact] + public void Position_should_throw_exception() + { + Assert.Throws(() => + { + var p = protoStream.Position; + }); + } + + [Fact] + public void Should_clean_underlaying_stream() + { + var field = this.protoStream.GetType().GetField("bufferStream", BindingFlags.NonPublic | BindingFlags.Instance); + Assert.NotNull(field); + + var streamValue = field.GetValue(this.protoStream); + Assert.Null(streamValue); + } + + [Fact] + public void Should_clean_underlaying_reader() + { + var field = this.protoStream.GetType().GetField("reader", BindingFlags.NonPublic | BindingFlags.Instance); + Assert.NotNull(field); + + var readerValue = field.GetValue(this.protoStream); + Assert.Null(readerValue); + } + + [Fact] + public void Should_clean_underlaying_writer() + { + var field = this.protoStream.GetType().GetField("writer", BindingFlags.NonPublic | BindingFlags.Instance); + Assert.NotNull(field); + + var writerValue = field.GetValue(this.protoStream); + Assert.Null(writerValue); + } + } + + public class When_the_proto_stream_has_been_disposed + { + private WeakReference weakRef; + + public When_the_proto_stream_has_been_disposed() + { + Stream stream; + using (var table = TestData.SmallDataTable()) + using (var tableReader = table.CreateDataReader()) + { + stream = new ProtoDataStream(tableReader); + } + + Assert.True(stream.CanRead); + + weakRef = new WeakReference(stream); + + stream.Dispose(); + } + + [Fact] + public void Proto_stream_should_collected_by_GC() + { + GC.Collect(); + GC.WaitForPendingFinalizers(); + + Assert.False(weakRef.IsAlive); + } } } } \ No newline at end of file diff --git a/test/protobuf-net-data.Tests/BackwardsCompatibilityTests.cs b/test/protobuf-net-data.Tests/BackwardsCompatibilityTests.cs index 7c0dc5f..d9e65bf 100644 --- a/test/protobuf-net-data.Tests/BackwardsCompatibilityTests.cs +++ b/test/protobuf-net-data.Tests/BackwardsCompatibilityTests.cs @@ -18,7 +18,6 @@ using System.IO; using System.Linq; using System.Reflection; -using SharpTestsEx; using Xunit; namespace ProtoBuf.Data.Tests @@ -81,7 +80,7 @@ public void Should_retain_binary_compatibility_when_reading() using (IDataReader reader = DataSerializer.Deserialize(stream)) actual.Load(reader, LoadOption.PreserveChanges, "A", "B", "C", "D"); - actual.HasErrors.Should().Be.False(); + Assert.False(actual.HasErrors); TestHelper.AssertContentsEqual(expected, actual); } @@ -105,7 +104,7 @@ public void Should_retain_binary_compatibility_when_writing() stream.Seek(0, SeekOrigin.Begin); - stream.GetBuffer().Take(expected.Length).Should().Have.SameSequenceAs(expected); + Assert.Equal(expected, stream.GetBuffer().Take(expected.Length)); } } @@ -125,11 +124,11 @@ public void Should_retain_binary_compatibility_with_previous_versions_when_writi stream.Seek(0, SeekOrigin.Begin); - stream.GetBuffer().Take(expected.Length).Should().Have.SameSequenceAs(expected); + Assert.Equal(expected, stream.GetBuffer().Take(expected.Length)); } } - //[Fact] + [Fact] //[Ignore("Only when our binary format changes (and we don't care about breaking old versions).")] private void RegenerateTestFile() { diff --git a/test/protobuf-net-data.Tests/DataSerializerTests.cs b/test/protobuf-net-data.Tests/DataSerializerTests.cs index 9b38be3..20c8390 100644 --- a/test/protobuf-net-data.Tests/DataSerializerTests.cs +++ b/test/protobuf-net-data.Tests/DataSerializerTests.cs @@ -14,7 +14,7 @@ using System.Data; using System.IO; -using Rhino.Mocks; +using Moq; using Xunit; namespace ProtoBuf.Data.Tests @@ -61,7 +61,7 @@ public class When_serializing_an_unsupported_type { DataTable originalTable; - class Foo {} + class Foo { } public When_serializing_an_unsupported_type() { @@ -86,7 +86,7 @@ public class When_serializing_a_data_table_with_no_rows public When_serializing_a_data_table_with_no_rows() { originalTable = new DataTable(); - originalTable.Columns.Add("ColumnA", typeof (int)); + originalTable.Columns.Add("ColumnA", typeof(int)); deserializedTable = TestHelper.SerializeAndDeserialize(originalTable); } @@ -134,7 +134,7 @@ public When_serializing_a_data_table_with_a_computed_column() originalTable = TestData.FromMatrix(matrix); var computed = TestData.FromMatrix(matrix); - computed.Columns.Add(new DataColumn("C", typeof (int), "A+B")); + computed.Columns.Add(new DataColumn("C", typeof(int), "A+B")); deserializedTable = TestHelper.SerializeAndDeserialize(computed); } @@ -163,7 +163,7 @@ public When_serializing_a_data_table_including_computed_columns() originalTable = TestData.FromMatrix(matrix); originalTable.Columns.Add(new DataColumn("C", typeof(int), "A+B")); - deserializedTable = TestHelper.SerializeAndDeserialize(originalTable, + deserializedTable = TestHelper.SerializeAndDeserialize(originalTable, new ProtoDataWriterOptions { IncludeComputedColumns = true }); } @@ -186,17 +186,20 @@ public void Should_not_throw_any_exception() new object[] {1, 2}, new object[] {10, 20}, }; - + using (var table = TestData.FromMatrix(matrix)) using (var reader = table.CreateDataReader()) using (var schemaTable = reader.GetSchemaTable()) { - var originalReader = MockRepository.GenerateMock(); + var moqReader = new Mock(); + moqReader.Setup(r => r.GetSchemaTable()).Returns(schemaTable).Verifiable(); + var originalReader = moqReader.Object; schemaTable.Columns.Remove("Expression"); - originalReader.Stub(r => r.GetSchemaTable()).Return(schemaTable); using (var stream = Stream.Null) new ProtoDataWriter().Serialize(stream, originalReader); + + moqReader.Verify(); } } } diff --git a/test/protobuf-net-data.Tests/MultipleDataTableTests.cs b/test/protobuf-net-data.Tests/MultipleDataTableTests.cs index b4571ee..c5e354c 100644 --- a/test/protobuf-net-data.Tests/MultipleDataTableTests.cs +++ b/test/protobuf-net-data.Tests/MultipleDataTableTests.cs @@ -15,7 +15,6 @@ using System; using System.Data; using System.IO; -using SharpTestsEx; using Xunit; namespace ProtoBuf.Data.Tests @@ -79,7 +78,7 @@ public When_advancing_to_the_next_result_set_but_still_in_the_middle_of_the_curr dataSet = new DataSet(); var tableWithNoRows = new DataTable(); - tableWithNoRows.Columns.Add("ColumnA", typeof (Guid)); + tableWithNoRows.Columns.Add("ColumnA", typeof(Guid)); var c = new[] { @@ -87,7 +86,7 @@ public When_advancing_to_the_next_result_set_but_still_in_the_middle_of_the_curr new object[] {9}, new object[] {8} }; - + dataSet.Tables.Add(TestData.FromMatrix(a)); dataSet.Tables.Add(TestData.FromMatrix(b)); dataSet.Tables.Add(tableWithNoRows); @@ -115,44 +114,44 @@ public void Dispose() [Fact] public void Should_produce_the_same_number_of_tables() { - reader.GetSchemaTable().Rows.Count.Should().Be(1); - reader.Read().Should().Be.True(); - reader.GetInt32(0).Should().Be(0); - reader.Read().Should().Be.True(); - reader.GetInt32(0).Should().Be(1); - reader.Read().Should().Be.True(); - reader.GetInt32(0).Should().Be(2); - reader.GetSchemaTable().Rows.Count.Should().Be(1); - - reader.NextResult().Should().Be.True(); - - - reader.GetSchemaTable().Rows.Count.Should().Be(2); - reader.Read().Should().Be.True(); - reader.GetString(0).Should().Be("A"); - reader.Read().Should().Be.True(); - reader.GetString(0).Should().Be("B"); - reader.GetSchemaTable().Rows.Count.Should().Be(2); - - reader.NextResult().Should().Be.True(); - reader.GetSchemaTable().Rows.Count.Should().Be(1); - reader.Read().Should().Be.False(); - reader.GetSchemaTable().Rows.Count.Should().Be(1); - - reader.NextResult().Should().Be.True(); - reader.GetSchemaTable().Rows.Count.Should().Be(0); - reader.Read().Should().Be.False(); - reader.GetSchemaTable().Rows.Count.Should().Be(0); - reader.NextResult().Should().Be.True(); - - reader.GetSchemaTable().Rows.Count.Should().Be(1); - reader.Read().Should().Be.True(); - reader.GetInt32(0).Should().Be(9); - reader.Read().Should().Be.True(); - reader.GetInt32(0).Should().Be(8); - reader.Read().Should().Be.False(); - reader.GetSchemaTable().Rows.Count.Should().Be(1); - reader.NextResult().Should().Be.False(); + Assert.Equal(1, reader.GetSchemaTable().Rows.Count); + Assert.True(reader.Read()); + Assert.Equal(0, reader.GetInt32(0)); + Assert.True(reader.Read()); + Assert.Equal(1, reader.GetInt32(0)); + Assert.True(reader.Read()); + Assert.Equal(2, reader.GetInt32(0)); + Assert.Equal(1, reader.GetSchemaTable().Rows.Count); + + Assert.True(reader.NextResult()); + + + Assert.Equal(2, reader.GetSchemaTable().Rows.Count); + Assert.True(reader.Read()); + Assert.Contains("A", reader.GetString(0)); + Assert.True(reader.Read()); + Assert.Contains("B", reader.GetString(0)); + Assert.Equal(2, reader.GetSchemaTable().Rows.Count); + + Assert.True(reader.NextResult()); + Assert.Equal(1, reader.GetSchemaTable().Rows.Count); + Assert.False(reader.Read()); + Assert.Equal(1, reader.GetSchemaTable().Rows.Count); + + Assert.True(reader.NextResult()); + Assert.Equal(0, reader.GetSchemaTable().Rows.Count); + Assert.False(reader.Read()); + Assert.Equal(0, reader.GetSchemaTable().Rows.Count); + Assert.True(reader.NextResult()); + + Assert.Equal(1, reader.GetSchemaTable().Rows.Count); + Assert.True(reader.Read()); + Assert.Equal(9, reader.GetInt32(0)); + Assert.True(reader.Read()); + Assert.Equal(8, reader.GetInt32(0)); + Assert.False(reader.Read()); + Assert.Equal(1, reader.GetSchemaTable().Rows.Count); + Assert.False(reader.NextResult()); } } @@ -197,19 +196,19 @@ public void Dispose() [Fact] public void Should_produce_the_same_number_of_tables() { - reader.GetSchemaTable().Rows.Count.Should().Be(0); - reader.Read().Should().Be.False(); - reader.GetSchemaTable().Rows.Count.Should().Be(0); - reader.NextResult().Should().Be.True(); - - reader.GetSchemaTable().Rows.Count.Should().Be(2); - reader.Read().Should().Be.True(); - reader.GetInt32(0).Should().Be(9); - reader.Read().Should().Be.True(); - reader.GetInt32(0).Should().Be(8); - reader.Read().Should().Be.False(); - reader.GetSchemaTable().Rows.Count.Should().Be(2); - reader.NextResult().Should().Be.False(); + Assert.Equal(0, reader.GetSchemaTable().Rows.Count); + Assert.False(reader.Read()); + Assert.Equal(0, reader.GetSchemaTable().Rows.Count); + Assert.True(reader.NextResult()); + + Assert.Equal(2, reader.GetSchemaTable().Rows.Count); + Assert.True(reader.Read()); + Assert.Equal(9, reader.GetInt32(0)); + Assert.True(reader.Read()); + Assert.Equal(8, reader.GetInt32(0)); + Assert.False(reader.Read()); + Assert.Equal(2, reader.GetSchemaTable().Rows.Count); + Assert.False(reader.NextResult()); } } @@ -224,7 +223,7 @@ public When_a_table_with_no_rows_is_immediately_followed_by_a_non_empty_one() dataSet = new DataSet(); var tableWithNoRows = new DataTable(); - tableWithNoRows.Columns.Add("Something", typeof (DateTime)); + tableWithNoRows.Columns.Add("Something", typeof(DateTime)); var c = new[] { new object[] {"Number", "Letter"}, @@ -255,19 +254,19 @@ public void Dispose() [Fact] public void Should_produce_the_same_number_of_tables() { - reader.GetSchemaTable().Rows.Count.Should().Be(1); - reader.Read().Should().Be.False(); - reader.GetSchemaTable().Rows.Count.Should().Be(1); - reader.NextResult().Should().Be.True(); - - reader.GetSchemaTable().Rows.Count.Should().Be(2); - reader.Read().Should().Be.True(); - reader.GetInt32(0).Should().Be(9); - reader.Read().Should().Be.True(); - reader.GetInt32(0).Should().Be(8); - reader.Read().Should().Be.False(); - reader.GetSchemaTable().Rows.Count.Should().Be(2); - reader.NextResult().Should().Be.False(); + Assert.Equal(1, reader.GetSchemaTable().Rows.Count); + Assert.False(reader.Read()); + Assert.Equal(1, reader.GetSchemaTable().Rows.Count); + Assert.True(reader.NextResult()); + + Assert.Equal(2, reader.GetSchemaTable().Rows.Count); + Assert.True(reader.Read()); + Assert.Equal(9, reader.GetInt32(0)); + Assert.True(reader.Read()); + Assert.Equal(8, reader.GetInt32(0)); + Assert.False(reader.Read()); + Assert.Equal(2, reader.GetSchemaTable().Rows.Count); + Assert.False(reader.NextResult()); } } } diff --git a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetBytesMethod.cs b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetBytesMethod.cs index 1d3aea9..09ecdbf 100644 --- a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetBytesMethod.cs +++ b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetBytesMethod.cs @@ -88,7 +88,7 @@ public void ShouldThrowExceptionWhenBufferOffsetIsLessThanZero() dataReader.Read(); // Assert - Assert.Throws("bufferOffset", () => dataReader.GetBytes(0, 0, new byte[1], -1, 1)); + Assert.Throws(() => dataReader.GetBytes(0, 0, new byte[1], -1, 1)); } [Fact] @@ -100,7 +100,7 @@ public void ShouldThrowExceptionWhenBufferOffsetIsGreaterThanBufferSize() dataReader.Read(); // Assert - Assert.Throws("bufferOffset", () => dataReader.GetBytes(0, 0, new byte[1], 10, 1)); + Assert.Throws(() => dataReader.GetBytes(0, 0, new byte[1], 10, 1)); } [Fact] @@ -112,7 +112,7 @@ public void ShouldThrowExceptionWhenBufferOffsetIsEqualToBufferSize() dataReader.Read(); // Assert - Assert.Throws("bufferOffset", () => dataReader.GetBytes(0, 0, new byte[1], 1, 1)); + Assert.Throws(() => dataReader.GetBytes(0, 0, new byte[1], 1, 1)); } [Fact] diff --git a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetCharsMethod.cs b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetCharsMethod.cs index 5912498..ba0df17 100644 --- a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetCharsMethod.cs +++ b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetCharsMethod.cs @@ -88,7 +88,7 @@ public void ShouldThrowExceptionWhenBufferOffsetIsLessThanZero() dataReader.Read(); // Assert - Assert.Throws("bufferOffset", () => dataReader.GetChars(0, 0, new char[1], -1, 1)); + Assert.Throws(() => dataReader.GetChars(0, 0, new char[1], -1, 1)); } [Fact] @@ -100,7 +100,7 @@ public void ShouldThrowExceptionWhenBufferOffsetIsGreaterThanBufferSize() dataReader.Read(); // Assert - Assert.Throws("bufferOffset", () => dataReader.GetChars(0, 0, new char[1], 10, 1)); + Assert.Throws(() => dataReader.GetChars(0, 0, new char[1], 10, 1)); } [Fact] @@ -112,7 +112,7 @@ public void ShouldThrowExceptionWhenBufferOffsetIsEqualToBufferSize() dataReader.Read(); // Assert - Assert.Throws("bufferOffset", () => dataReader.GetChars(0, 0, new char[1], 1, 1)); + Assert.Throws(() => dataReader.GetChars(0, 0, new char[1], 1, 1)); } [Fact] diff --git a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetDataTypeName.cs b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetDataTypeName.cs index c18ba49..9bc2c4b 100644 --- a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetDataTypeName.cs +++ b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetDataTypeName.cs @@ -32,7 +32,7 @@ public void ShouldReturnCorrespondingDataTypeName() var result = dataReader.GetDataTypeName(0); // Assert - Assert.Equal(value.GetType().Name, result); + Assert.Contains(value.GetType().Name, result); } } } diff --git a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetNameMethod.cs b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetNameMethod.cs index 3250c14..1633fed 100644 --- a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetNameMethod.cs +++ b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetNameMethod.cs @@ -48,7 +48,7 @@ public void ShouldReturnCorrespondingName() var result = dataReader.GetName(0); // Assert - Assert.Equal(dataTable.Columns[0].ColumnName, result); + Assert.Contains(dataTable.Columns[0].ColumnName, result); } } } diff --git a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetSchemaTableMethod.cs b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetSchemaTableMethod.cs index b071b8f..26b1b18 100644 --- a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetSchemaTableMethod.cs +++ b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetSchemaTableMethod.cs @@ -32,7 +32,7 @@ public void ShouldSetTableName() var schemaTable = dataReader.GetSchemaTable(); // Assert - Assert.Equal("SchemaTable", schemaTable.TableName); + Assert.Contains("SchemaTable", schemaTable.TableName); } [Fact] diff --git a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetStringMethod.cs b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetStringMethod.cs index b4a3077..43b42ac 100644 --- a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetStringMethod.cs +++ b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetStringMethod.cs @@ -66,7 +66,7 @@ public void ShouldReturnCorrespondingValue() var result = dataReader.GetString(0); // Assert - Assert.Equal(value, result); + Assert.Contains(value, result); } } } diff --git a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetValueMethod.cs b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetValueMethod.cs index 83f547b..79673d8 100644 --- a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetValueMethod.cs +++ b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetValueMethod.cs @@ -56,7 +56,7 @@ public void ShouldReturnCorrespondingValue() var result = dataReader.GetValue(0); // Assert - Assert.Equal(value, Convert.ToString(result)); + Assert.Contains(value, Convert.ToString(result)); } } } diff --git a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetValuesMethod.cs b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetValuesMethod.cs index da06a81..c3075db 100644 --- a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetValuesMethod.cs +++ b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetValuesMethod.cs @@ -19,7 +19,7 @@ public void ShouldThrowExceptionWhenValuesIsNull() dataReader.Close(); // Assert - Assert.Throws("values", () => dataReader.GetValues(null)); + Assert.Throws(() => dataReader.GetValues(null)); } [Fact] @@ -59,7 +59,7 @@ public void ShouldReturnCorrespondingValues() dataReader.GetValues(result); // Assert - Assert.Equal(new[] { value }, result); + Assert.Equal(new object[] { value }, result); } [Fact] diff --git a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheNextResultMethod.cs b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheNextResultMethod.cs index 0e929b2..271d2a4 100644 --- a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheNextResultMethod.cs +++ b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheNextResultMethod.cs @@ -111,7 +111,7 @@ public void ShouldChangeColumns() // Assert dataReader.Read(); - Assert.Equal(dataSet.Tables[1].Columns[0].ColumnName, dataReader.GetName(0)); + Assert.Contains(dataSet.Tables[1].Columns[0].ColumnName, dataReader.GetName(0)); } } } diff --git a/test/protobuf-net-data.Tests/ProtoDataStreamTests.cs b/test/protobuf-net-data.Tests/ProtoDataStreamTests.cs index 7311e26..476c5e6 100644 --- a/test/protobuf-net-data.Tests/ProtoDataStreamTests.cs +++ b/test/protobuf-net-data.Tests/ProtoDataStreamTests.cs @@ -13,11 +13,16 @@ // limitations under the License. using System; +using System.Collections; +using System.Collections.Generic; using System.Data; using System.IO; using System.Linq; -using SharpTestsEx; +using System.Threading.Tasks; using Xunit; +#if NET40 +using Xunit.Extensions; +#endif namespace ProtoBuf.Data.Tests { @@ -30,7 +35,7 @@ public class When_reading_from_a_stream_less_than_protobuf_nets_flush_size private byte[] expectedBytes; private byte[] actualBytes; private DataTableReader reader; - + public When_reading_from_a_stream_less_than_protobuf_nets_flush_size() { var testData = TestData.SmallDataTable(); @@ -54,8 +59,8 @@ public When_reading_from_a_stream_less_than_protobuf_nets_flush_size() [Fact] public void It_should_be_binary_equal_to_the_data_serializer_version() { - actualBytes.Length.Should().Be.EqualTo(expectedBytes.Length); - actualBytes.Should().Have.SameSequenceAs(expectedBytes); + Assert.Equal(this.expectedBytes.Length, this.actualBytes.Length); + Assert.Equal(this.expectedBytes, this.actualBytes); } [Fact] @@ -94,8 +99,9 @@ public When_reading_from_a_stream() [Fact] public void It_should_be_binary_equal_to_the_data_serializer_version() { + Assert.Equal(this.expectedBytes.Length, this.actualBytes.Length); //actualBytes.Length.Should().Be.EqualTo(expectedBytes.Length); - actualBytes.Should().Have.SameSequenceAs(expectedBytes); + Assert.Equal(this.expectedBytes, this.actualBytes); } [Fact] @@ -129,14 +135,17 @@ public void It_should_populate_the_buffer_correctly() using (var stream = new ProtoDataStream(reader)) { var buffer1 = new byte[16]; - stream.Read(buffer1, 0, buffer1.Length).Should().Be(buffer1.Length); - buffer1.Should().Have.SameSequenceAs(expectedBytes.Take(buffer1.Length)); + var buffer1Readed = stream.Read(buffer1, 0, buffer1.Length); + Assert.Equal(buffer1.Length, buffer1Readed); + Assert.Equal(this.expectedBytes.Take(buffer1.Length), buffer1); - stream.Read(buffer1, 0, 0).Should().Be(0); + buffer1Readed = stream.Read(buffer1, 0, 0); + Assert.Equal(0, buffer1Readed); var buffer2 = new byte[16 * 1024]; - stream.Read(buffer2, 0, buffer2.Length).Should().Be(buffer2.Length); - buffer2.Should().Have.SameSequenceAs(expectedBytes.Skip(buffer1.Length).Take(buffer2.Length)); + var buffer2Readed = stream.Read(buffer2, 0, buffer2.Length); + Assert.Equal(buffer2.Length, buffer2Readed); + Assert.Equal(expectedBytes.Skip(buffer1.Length).Take(buffer2.Length), buffer2); } } } @@ -177,14 +186,14 @@ public class When_reading_from_a_stream_containing_multiple_data_tables public When_reading_from_a_stream_containing_multiple_data_tables() { var testData = new DataSet - { - Tables = + { + Tables = { TestData.GenerateRandomDataTable(10, 50), TestData.GenerateRandomDataTable(5, 100), TestData.GenerateRandomDataTable(20, 10000) } - }; + }; using (var r = testData.CreateDataReader()) using (var memoryStream = new MemoryStream()) @@ -205,8 +214,141 @@ public When_reading_from_a_stream_containing_multiple_data_tables() [Fact] public void It_should_be_binary_equal_to_the_data_serializer_version() { - actualBytes.Length.Should().Be.EqualTo(expectedBytes.Length); - actualBytes.Should().Have.SameSequenceAs(expectedBytes); + Assert.Equal(this.expectedBytes.Length, this.actualBytes.Length); + Assert.Equal(this.expectedBytes, this.actualBytes); + } + + [Fact] + public void It_should_dispose_the_reader() + { + Assert.Throws(() => reader.Read()); + } + } + + public class When_copies_from_proto_stream_with_variuos_buffers_sizes + { + private byte[] expectedBytes; + private DataTable testData; + + public When_copies_from_proto_stream_with_variuos_buffers_sizes() + { + testData = TestData.SmallDataTable(); + + using (var r = testData.CreateDataReader()) + using (var memoryStream = new MemoryStream()) + { + DataSerializer.Serialize(memoryStream, r); + expectedBytes = memoryStream.GetTrimmedBuffer(); + } + } + + ~When_copies_from_proto_stream_with_variuos_buffers_sizes() + { + testData.Dispose(); + testData = null; + expectedBytes = null; + } + +#if !NET40 + + [Theory] + [ClassData(typeof(BuffersData))] + public async Task It_should_copy_async_with_various_buffers(int protoBufferSize, int copyBufferSize) + { + + byte[] actualBytes_; + using (var reader = testData.CreateDataReader()) + using (var stream = new ProtoDataStream(reader, protoBufferSize * 1024)) + using (var memoryStream = new MemoryStream()) + { + + await stream.CopyToAsync(memoryStream, copyBufferSize * 1024); + actualBytes_ = memoryStream.GetTrimmedBuffer(); + } + + Assert.Equal(expectedBytes.LongLength, actualBytes_.LongLength); + Assert.Equal(expectedBytes, actualBytes_); + } +#endif + + + [Theory] + [ClassData(typeof(BuffersData))] + public void It_should_copy_with_various_buffers(int protoBufferSize, int copyBufferSize) + { + byte[] actualBytes_; + using (var reader = testData.CreateDataReader()) + using (var stream = new ProtoDataStream(reader, protoBufferSize * 1024)) + using (var memoryStream = new MemoryStream()) + { + + stream.CopyTo(memoryStream, copyBufferSize * 1024); + actualBytes_ = memoryStream.GetTrimmedBuffer(); + } + + Assert.Equal(expectedBytes.LongLength, actualBytes_.LongLength); + Assert.Equal(expectedBytes, actualBytes_); + } + + class BuffersData : IEnumerable + { + private readonly int[] _protoBufferSizes = { 128, 137, 1024 }; + private readonly int[] _copyBufferSizes = { 64, 75, 128, 512 }; + + public IEnumerator GetEnumerator() + { + foreach (var protoBufferSize in this._protoBufferSizes) + { + foreach (var copyBufferSize in this._copyBufferSizes) + { + yield return new object[] { protoBufferSize, copyBufferSize }; + } + } + } + + IEnumerator IEnumerable.GetEnumerator() => this.GetEnumerator(); + } + } + + public class When_reading_from_a_stream_containing_multiple_data_tables_with_big_buffer + { + private byte[] expectedBytes; + private byte[] actualBytes; + private IDataReader reader; + + public When_reading_from_a_stream_containing_multiple_data_tables_with_big_buffer() + { + var testData = new DataSet + { + Tables = + { + TestData.GenerateRandomDataTable(10, 50), + TestData.GenerateRandomDataTable(5, 100), + TestData.GenerateRandomDataTable(20, 10000) + } + }; + + using (var r = testData.CreateDataReader()) + using (var memoryStream = new MemoryStream()) + { + DataSerializer.Serialize(memoryStream, r); + expectedBytes = memoryStream.GetTrimmedBuffer(); + } + + reader = testData.CreateDataReader(); + using (var stream = new ProtoDataStream(reader, 50 * 1024 * 1024))//50 Mb buffer which + using (var memoryStream = new MemoryStream()) + { + stream.CopyTo(memoryStream); + actualBytes = memoryStream.GetTrimmedBuffer(); + } + } + + [Fact] + public void It_should_be_binary_equal_to_the_data_serializer_version() + { + Assert.Equal(this.expectedBytes.LongLength, this.actualBytes.LongLength); + Assert.Equal(this.expectedBytes, this.actualBytes); } [Fact] diff --git a/test/protobuf-net-data.Tests/protobuf-net-data.Tests.csproj b/test/protobuf-net-data.Tests/protobuf-net-data.Tests.csproj index 9cfbf13..88ba444 100644 --- a/test/protobuf-net-data.Tests/protobuf-net-data.Tests.csproj +++ b/test/protobuf-net-data.Tests/protobuf-net-data.Tests.csproj @@ -3,21 +3,48 @@ full false - net471 + net40;net47;net471;netcoreapp2.0 true + + true + + + + false + + + false + + + false + + - + - - + + + - - + + + + + + + + + + + + + + From c151c570fbed7d982b0dbb58805c87ae46af14c4 Mon Sep 17 00:00:00 2001 From: Alexander Grechishkin Date: Sat, 24 Mar 2018 22:04:16 +0200 Subject: [PATCH 3/6] fix Disposing pattern for ProtoDataReader --- src/protobuf-net-data/ProtoDataReader.cs | 53 ++++++++++++------------ 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/src/protobuf-net-data/ProtoDataReader.cs b/src/protobuf-net-data/ProtoDataReader.cs index 1c49787..e680255 100644 --- a/src/protobuf-net-data/ProtoDataReader.cs +++ b/src/protobuf-net-data/ProtoDataReader.cs @@ -20,7 +20,9 @@ namespace ProtoBuf.Data using System.Data; using System.IO; using ProtoBuf.Data.Internal; +#if NET45 || NETSTANDARD20 using System.Runtime.CompilerServices; +#endif /// /// A custom for de-serializing a protocol-buffer binary stream back @@ -33,11 +35,11 @@ public sealed class ProtoDataReader : IDataReader private Stream stream; private object[] currentRow; private DataTable dataTable; - private bool disposed; private ProtoReader reader; private int currentField; private SubItemToken currentTableToken; private bool reachedEndOfCurrentTable; + private bool isClosed; /// /// Initializes a new instance of the class. @@ -92,7 +94,7 @@ public int Depth } } - public bool IsClosed => this.disposed; + public bool IsClosed => this.isClosed; /// /// Gets the number of rows changed, inserted, or deleted. @@ -341,7 +343,25 @@ public bool IsDBNull(int i) public void Close() { - this.Dispose(); + if (this.reader != null) + { + this.reader.Dispose(); + this.reader = null; + } + + if (this.stream != null) + { + this.stream.Dispose(); + this.stream = null; + } + + if (this.dataTable != null) + { + this.dataTable.Dispose(); + this.dataTable = null; + } + + this.isClosed = true; } public bool NextResult() @@ -398,36 +418,15 @@ public bool Read() public void Dispose() { - Dispose(true); + this.Dispose(true); GC.SuppressFinalize(this); } private void Dispose(bool disposing) { - if (!disposed) + if (disposing) { - if (disposing) - { - if (reader != null) - { - reader.Dispose(); - reader = null; - } - - if (stream != null) - { - stream.Dispose(); - stream = null; - } - - if (dataTable != null) - { - dataTable.Dispose(); - dataTable = null; - } - } - - disposed = true; + this.Close(); } } From 8e8bd798492d50fff4b51d97a67cc3f9fddb4d6b Mon Sep 17 00:00:00 2001 From: Alexander Grechishkin Date: Sat, 24 Mar 2018 22:27:51 +0200 Subject: [PATCH 4/6] revert Assert.Contains to to Assert.Equal for strings, add analyzer rule suppression for NET40 --- test/protobuf-net-data.Tests/GlobalSuppressions.cs | 10 ++++++++++ test/protobuf-net-data.Tests/MultipleDataTableTests.cs | 4 ++-- .../ProtoBufDataReaderTests.TheGetDataTypeName.cs | 2 +- .../ProtoBufDataReaderTests.TheGetNameMethod.cs | 2 +- .../ProtoBufDataReaderTests.TheGetSchemaTableMethod.cs | 2 +- .../ProtoBufDataReaderTests.TheGetStringMethod.cs | 2 +- .../ProtoBufDataReaderTests.TheGetValueMethod.cs | 2 +- .../ProtoBufDataReaderTests.TheNextResultMethod.cs | 2 +- 8 files changed, 18 insertions(+), 8 deletions(-) create mode 100644 test/protobuf-net-data.Tests/GlobalSuppressions.cs diff --git a/test/protobuf-net-data.Tests/GlobalSuppressions.cs b/test/protobuf-net-data.Tests/GlobalSuppressions.cs new file mode 100644 index 0000000..47a8833 --- /dev/null +++ b/test/protobuf-net-data.Tests/GlobalSuppressions.cs @@ -0,0 +1,10 @@ + +// This file is used by Code Analysis to maintain SuppressMessage +// attributes that are applied to this project. +// Project-level suppressions either have no target or are given +// a specific target and scoped to a namespace, type, member, etc. + +#if NET40 +[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Assertions", "xUnit2006:Do not use invalid string equality check", Justification = "", Scope = "module")] +#endif + diff --git a/test/protobuf-net-data.Tests/MultipleDataTableTests.cs b/test/protobuf-net-data.Tests/MultipleDataTableTests.cs index c5e354c..0e9c06a 100644 --- a/test/protobuf-net-data.Tests/MultipleDataTableTests.cs +++ b/test/protobuf-net-data.Tests/MultipleDataTableTests.cs @@ -128,9 +128,9 @@ public void Should_produce_the_same_number_of_tables() Assert.Equal(2, reader.GetSchemaTable().Rows.Count); Assert.True(reader.Read()); - Assert.Contains("A", reader.GetString(0)); + Assert.Equal("A", reader.GetString(0)); Assert.True(reader.Read()); - Assert.Contains("B", reader.GetString(0)); + Assert.Equal("B", reader.GetString(0)); Assert.Equal(2, reader.GetSchemaTable().Rows.Count); Assert.True(reader.NextResult()); diff --git a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetDataTypeName.cs b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetDataTypeName.cs index 9bc2c4b..c18ba49 100644 --- a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetDataTypeName.cs +++ b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetDataTypeName.cs @@ -32,7 +32,7 @@ public void ShouldReturnCorrespondingDataTypeName() var result = dataReader.GetDataTypeName(0); // Assert - Assert.Contains(value.GetType().Name, result); + Assert.Equal(value.GetType().Name, result); } } } diff --git a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetNameMethod.cs b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetNameMethod.cs index 1633fed..3250c14 100644 --- a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetNameMethod.cs +++ b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetNameMethod.cs @@ -48,7 +48,7 @@ public void ShouldReturnCorrespondingName() var result = dataReader.GetName(0); // Assert - Assert.Contains(dataTable.Columns[0].ColumnName, result); + Assert.Equal(dataTable.Columns[0].ColumnName, result); } } } diff --git a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetSchemaTableMethod.cs b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetSchemaTableMethod.cs index 26b1b18..b071b8f 100644 --- a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetSchemaTableMethod.cs +++ b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetSchemaTableMethod.cs @@ -32,7 +32,7 @@ public void ShouldSetTableName() var schemaTable = dataReader.GetSchemaTable(); // Assert - Assert.Contains("SchemaTable", schemaTable.TableName); + Assert.Equal("SchemaTable", schemaTable.TableName); } [Fact] diff --git a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetStringMethod.cs b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetStringMethod.cs index 43b42ac..b4a3077 100644 --- a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetStringMethod.cs +++ b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetStringMethod.cs @@ -66,7 +66,7 @@ public void ShouldReturnCorrespondingValue() var result = dataReader.GetString(0); // Assert - Assert.Contains(value, result); + Assert.Equal(value, result); } } } diff --git a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetValueMethod.cs b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetValueMethod.cs index 79673d8..83f547b 100644 --- a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetValueMethod.cs +++ b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheGetValueMethod.cs @@ -56,7 +56,7 @@ public void ShouldReturnCorrespondingValue() var result = dataReader.GetValue(0); // Assert - Assert.Contains(value, Convert.ToString(result)); + Assert.Equal(value, Convert.ToString(result)); } } } diff --git a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheNextResultMethod.cs b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheNextResultMethod.cs index 271d2a4..0e929b2 100644 --- a/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheNextResultMethod.cs +++ b/test/protobuf-net-data.Tests/ProtoBufDataReaderTests.TheNextResultMethod.cs @@ -111,7 +111,7 @@ public void ShouldChangeColumns() // Assert dataReader.Read(); - Assert.Contains(dataSet.Tables[1].Columns[0].ColumnName, dataReader.GetName(0)); + Assert.Equal(dataSet.Tables[1].Columns[0].ColumnName, dataReader.GetName(0)); } } } From 13abda9f17240c41a4bfbaef4b51228d1ecb6ff2 Mon Sep 17 00:00:00 2001 From: Alexander Grechishkin Date: Sat, 24 Mar 2018 22:42:18 +0200 Subject: [PATCH 5/6] cleanup protobuf-net-data.Tests project file --- .../protobuf-net-data.Tests.csproj | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/test/protobuf-net-data.Tests/protobuf-net-data.Tests.csproj b/test/protobuf-net-data.Tests/protobuf-net-data.Tests.csproj index 88ba444..4cbc8ca 100644 --- a/test/protobuf-net-data.Tests/protobuf-net-data.Tests.csproj +++ b/test/protobuf-net-data.Tests/protobuf-net-data.Tests.csproj @@ -3,29 +3,15 @@ full false - net40;net47;net471;netcoreapp2.0 + net40;net471;netcoreapp2.0 true - - true - - - - false - - - false - - - false - - - + @@ -33,7 +19,7 @@ - + From dd6a168c34b1ffa563e57ab5d84b68a08f3c1594 Mon Sep 17 00:00:00 2001 From: Alexander Grechishkin Date: Sat, 24 Mar 2018 22:50:21 +0200 Subject: [PATCH 6/6] rever .gitignore to original state --- .gitignore | 7 ------- 1 file changed, 7 deletions(-) diff --git a/.gitignore b/.gitignore index 76aa937..acfed39 100644 --- a/.gitignore +++ b/.gitignore @@ -98,13 +98,6 @@ ipch/ *.cachefile *.VC.db *.VC.VC.opendb -obj/ -[Bb]in -[Dd]ebug*/ -[Rr]elease*/ -Ankh.NoLoad -.nuget/nuget.exe -.vs/ # Visual Studio profiler *.psess