Ejemplo n.º 1
0
        public void CanSerializeNull()
        {
            var expected = new Something
            {
                Else = null
            };

            Serialize(expected);
            Reset();
            var actual = Deserialize <Something>();

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 2
0
        public void CanSerializeObject()
        {
            var expected = new Something
            {
                BoolProp  = true,
                Int32Prop = 123,
                NullableInt32PropHasValue = 888,
                StringProp = "hello",
            };

            Serialize(expected);
            Reset();
            var actual = Deserialize <Something>();

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 3
0
        public void CanSerializePolymorphicObject()
        {
            var expected = new Something
            {
                Else = new OtherElse
                {
                    Name = "Foo",
                    More = "Bar"
                }
            };

            Serialize(expected);
            Reset();
            var actual = Deserialize <Something>();

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 4
0
        public void CanSerializeObjects()
        {
            var expected1 = new Something
            {
                StringProp = "First"
            };
            var expected2 = new Something
            {
                StringProp = "Second"
            };
            var expected3 = new Something
            {
                StringProp = "Last"
            };

            Serialize(expected1);
            Serialize(expected2);
            Serialize(expected3);
            Reset();
            Assert.Equal(expected1, Deserialize <Something>());
            Assert.Equal(expected2, Deserialize <Something>());
            Assert.Equal(expected3, Deserialize <Something>());
        }
Ejemplo n.º 5
0
        public void CanSerializeObjectsKnownTypes()
        {
            CustomInit(new Serializer(new SerializerOptions(knownTypes: new[] { typeof(Something) })));
            var expected1 = new Something
            {
                StringProp = "First"
            };
            var expected2 = new Something
            {
                StringProp = "Second"
            };
            var expected3 = new Something
            {
                StringProp = "Last"
            };

            Serialize(expected1);
            Serialize(expected2);
            Serialize(expected3);
            Reset();
            Assert.Equal(expected1, Deserialize <Something>());
            Assert.Equal(expected2, Deserialize <Something>());
            Assert.Equal(expected3, Deserialize <Something>());
        }