コード例 #1
0
        public void SerializeToTextWriter(BigObject obj)
        {
            var writer = new StringWriter();

            _converter.Serialize(obj, writer);

            var serialized = writer.ToString();
            var result     = JsonConvert.DeserializeObject <BigObject>(serialized);

            result.Should().BeEquivalentTo(obj);
        }
コード例 #2
0
        public void Serialize_Array_Object(Boo[] array)
        {
            var json         = _converter.Serialize(array);
            var deserialized = JsonConvert.DeserializeObject <Boo[]>(json);

            for (var i = 0; i < array.Length; i++)
            {
                var element             = array[i];
                var deserializedElement = deserialized[i];

                Assert.Equal(element.Bool, deserializedElement.Bool);
                Assert.Equal(element.Double, deserializedElement.Double);
                Assert.Equal(element.Float, deserializedElement.Float);
                Assert.Equal(element.Int, deserializedElement.Int);
            }
        }