public void ShouldSerializeTimeSpanValue() { // Arrange var value = TimeSpan.FromTicks(1); var dataReader = this.CreateDataReader(value); // Act var reader = new ProtoReader(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); readerContext.ReadUntilFieldValue(); Assert.Equal(value, BclHelpers.ReadTimeSpan(reader)); }
public void ShouldSerializeInt32Value() { // Arrange var value = 42; var dataReader = this.CreateDataReader(value); // Act var reader = new ProtoReader(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); readerContext.ReadUntilFieldValue(); Assert.Equal(value, reader.ReadInt32()); }
public void ShouldSerializeCharArrayValue() { // Arrange var value = new[] { 'f', 'o', 'o' }; var dataReader = this.CreateDataReader(value); // Act var reader = new ProtoReader(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); readerContext.ReadUntilFieldValue(); Assert.Equal(value, reader.ReadString().ToCharArray()); }
public void ShouldSerializeDateTimeValue() { // Arrange var value = new DateTime(1969, 10, 29, 22, 30, 0); var dataReader = this.CreateDataReader(value); // Act var reader = new ProtoReader(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); readerContext.ReadUntilFieldValue(); Assert.Equal(value, BclHelpers.ReadDateTime(reader)); }
public void ShouldSerializeByteArrayValue() { // Arrange var value = new[] { (byte)42, (byte)42 }; var dataReader = this.CreateDataReader(value); // Act var reader = new ProtoReader(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); readerContext.ReadUntilFieldValue(); Assert.Equal(value, ProtoReader.AppendBytes(null, reader)); }
public void ShouldSerializeDecimalValue() { // Arrange var value = 42m; var dataReader = this.CreateDataReader(value); // Act var reader = new ProtoReader(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); readerContext.ReadUntilFieldValue(); Assert.Equal(value, BclHelpers.ReadDecimal(reader)); }
public void ShouldSerializeCharValue() { // Arrange var value = ';'; var dataReader = this.CreateDataReader(value); // Act var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); readerContext.ReadUntilFieldValue(); Assert.Equal(value, (char)reader.ReadInt16()); }
public void ShouldSerializeGuidValue() { // Arrange var value = Guid.NewGuid(); var dataReader = this.CreateDataReader(value); // Act var reader = ProtoReader.Create(this.Serialize(dataReader), null, null); // Assert var readerContext = new ProtoReaderContext(reader); readerContext.ReadUntilFieldValue(); Assert.Equal(value, BclHelpers.ReadGuid(reader)); }
public void ShouldSerializeField() { // Arrange var value = "foo"; var dataReader = this.CreateDataReader(value); var stream = new ProtoDataStream(dataReader); // Act var reader = ProtoReader.Create(this.CopyStream(stream), null, null); // Assert var readerContext = new ProtoReaderContext(reader); readerContext.ReadUntilFieldValue(); Assert.Equal(value, reader.ReadString()); }