Exemplo n.º 1
0
        public void SerializeDeserializeDictionaryTest()
        {
            // arrange
            var stream = new MemoryStream();
            var source = new Dictionary <Guid, string>
            {
                { Guid.NewGuid(), "Test1" },
                { Guid.NewGuid(), "Test2" }
            };

            var wrapIn = new Wrap1
            {
                Dict = source
            };

            // act
            Serializer.Serialize(stream, wrapIn);
            stream.Seek(0, SeekOrigin.Begin);
            var wrapOut = Serializer.Deserialize <Wrap1>(stream);
            var copy    = wrapOut.Dict;

            // assert
            Assert.AreEqual(2, copy.Count);
            Assert.AreEqual(source.First().Key, copy.First().Key);
            Assert.AreEqual(source.First().Value, copy.First().Value);
            Assert.AreEqual(source.Last().Key, copy.Last().Key);
            Assert.AreEqual(source.Last().Value, copy.Last().Value);
        }
Exemplo n.º 2
0
        public void SerializeDeserializeEmptyDictionaryTest()
        {
            // arrange
            var stream = new MemoryStream();
            var source = new Dictionary <Guid, string>();

            var wrapIn = new Wrap1
            {
                Dict = source
            };

            // act
            Serializer.Serialize(stream, wrapIn);
            stream.Seek(0, SeekOrigin.Begin);
            var wrapOut = Serializer.Deserialize <Wrap1>(stream);
            var copy    = wrapOut.Dict;

            // assert
            Assert.IsNull(copy);
        }