public void ShouldSerializeDataSetUsingOptions() { // Arrange var dataSet = new DataSet(); dataSet.Tables.Add(this.CreateTable(new char[0])); var stream = new MemoryStream(); var options = new ProtoDataWriterOptions() { SerializeEmptyArraysAsNull = true }; // Act DataSerializer.Serialize(stream, dataSet, options); // Assert stream.Position = 0; var dataReader = new ProtoDataReader(stream); dataReader.Read(); Assert.True(dataReader.IsDBNull(0)); }
public void ShouldSerializeDataTable() { // Arrange var stream = new MemoryStream(); // Act DataSerializer.Serialize(stream, this.CreateTable(0)); // Assert stream.Position = 0; var dataReader = new ProtoDataReader(stream); Assert.Equal(1, dataReader.FieldCount); }
public void ShouldAcceptTrailingFieldHeaders() { // Arrange var stream = new MemoryStream(); using (var writer = ProtoWriter.Create(stream, null, null)) { ProtoWriter.WriteFieldHeader(1, WireType.StartGroup, writer); var resultToken = ProtoWriter.StartSubItem(0, writer); ProtoWriter.WriteFieldHeader(2, WireType.StartGroup, writer); var columnToken = ProtoWriter.StartSubItem(1, writer); ProtoWriter.WriteFieldHeader(1, WireType.String, writer); ProtoWriter.WriteString("foo", writer); ProtoWriter.WriteFieldHeader(2, WireType.Variant, writer); ProtoWriter.WriteInt32((int)3, writer); ProtoWriter.EndSubItem(columnToken, writer); ProtoWriter.WriteFieldHeader(3, WireType.StartGroup, writer); var recordToken = ProtoWriter.StartSubItem(1, writer); ProtoWriter.WriteFieldHeader(1, WireType.Variant, writer); ProtoWriter.WriteInt32((int)1, writer); ProtoWriter.WriteFieldHeader(2, WireType.Variant, writer); ProtoWriter.WriteInt32((int)1, writer); ProtoWriter.EndSubItem(recordToken, writer); ProtoWriter.EndSubItem(resultToken, writer); } stream.Position = 0; var dataReader = new ProtoDataReader(stream); // Assert dataReader.Read(); }