Exemple #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));
            }
Exemple #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());
            }
Exemple #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());
            }
Exemple #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));
            }
Exemple #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));
            }
Exemple #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));
            }
Exemple #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());
            }
Exemple #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));
            }
Exemple #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());
            }