Beispiel #1
0
        public void Should_work_same_way_as_memory_stream_on_read()
        {
            var serializer = new JsonSerializer();

            var origin = new TestClass
            {
                Name       = "FFasdf fasd  FASDfas   fadsfa  dafsdf  asdf a fsd ",
                CreatedAt  = DateTime.Now,
                IsObsolete = true,
                Count      = 31241325351
            };

            using (var writer = new JsonTextWriter(new StreamWriter(_ethalonStream)))
            {
                serializer.Serialize(writer, origin);
            }

            _testStream.ChangeBuffer(_ethalonBuffer);

            using (var reader = new JsonTextReader(new StreamReader(_testStream)))
            {
                var reburnished = serializer.Deserialize <TestClass>(reader);

                Assert.That(reburnished.Name, Is.EqualTo(origin.Name));
                Assert.That(reburnished.CreatedAt, Is.EqualTo(origin.CreatedAt));
                Assert.That(reburnished.IsObsolete, Is.EqualTo(origin.IsObsolete));
                Assert.That(reburnished.Count, Is.EqualTo(origin.Count));
            }
        }