Beispiel #1
0
            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));
            }
Beispiel #2
0
            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());
            }
Beispiel #3
0
            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());
            }
Beispiel #4
0
            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));
            }
Beispiel #5
0
            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));
            }
Beispiel #6
0
            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));
            }
Beispiel #7
0
            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());
            }
Beispiel #8
0
            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));
            }
Beispiel #9
0
            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());
            }