Example #1
0
        public void StringSerializerTest()
        {
            var testSerializer = new MessagePackObjectSerializer <string>();
            var serializedData = testSerializer.Serialize(TestString);

            Assert.NotEmpty(serializedData);

            var deserializedString = testSerializer.Deserialize(serializedData);

            Assert.False(string.IsNullOrEmpty(deserializedString));
            Assert.Equal(TestString, deserializedString);
        }
Example #2
0
        public void SimpleValueTypeSerializerTest()
        {
            var originalValue = 7;

            var testSerializer = new MessagePackObjectSerializer <int>();
            var serializedData = testSerializer.Serialize(originalValue);

            Assert.NotEmpty(serializedData);

            var deserializedValue = testSerializer.Deserialize(serializedData);

            Assert.Equal(originalValue, deserializedValue);

            originalValue  = 1028;
            serializedData = testSerializer.Serialize(originalValue);

            Assert.NotEmpty(serializedData);

            deserializedValue = testSerializer.Deserialize(serializedData);

            Assert.Equal(originalValue, deserializedValue);
        }
Example #3
0
        public void ImmutableTypeSerializerTest()
        {
            var testObject = ImmutableSerializableObject.GetTestInstance();

            var testSerializer = new MessagePackObjectSerializer <ImmutableSerializableObject>();
            var serializedData = testSerializer.Serialize(testObject);

            Assert.NotEmpty(serializedData);

            var deserializedObject = testSerializer.Deserialize(serializedData);

            Assert.NotNull(deserializedObject);
            Assert.NotNull(deserializedObject.NestedObject);
            Assert.Equal(TestString, deserializedObject.StringProperty);
            Assert.Equal(TestInt, deserializedObject.IntProperty);
            Assert.Equal(TestDouble, deserializedObject.NestedObject.DoubleProperty);
        }