示例#1
0
        public void Serialize_MemoryStream_Serializes()
        {
            var chrysalis = MockChrysalisFactory.CreateChrysalis();

            using (var stream = new MemoryStream())
            {
                SerializationHelper.Serialize(chrysalis, stream);
            }
        }
示例#2
0
        public void Serialize_XmlTextWriter_Serializes()
        {
            var chrysalis = MockChrysalisFactory.CreateChrysalis();

            using (var stream = new MemoryStream())
                using (var textWriter = new XmlTextWriter(stream, Encoding.UTF8))
                {
                    textWriter.Formatting = Formatting.Indented;
                    SerializationHelper.Serialize(chrysalis, textWriter);
                }
        }
示例#3
0
        public void Deserialize_MemoryStream_Deserializes()
        {
            var chrysalis = MockChrysalisFactory.CreateChrysalis();

            using (var stream = new MemoryStream())
            {
                SerializationHelper.Serialize(chrysalis, stream);
                stream.Position = 0;
                var inputChrysalis = SerializationHelper.Deserialize(stream);
                Assert.True(chrysalis.RootGroups.First().Equals(inputChrysalis.RootGroups.First()));
            }
        }
示例#4
0
        public void Deserialize_XmlReader_Deserializes()
        {
            var        chrysalis = MockChrysalisFactory.CreateChrysalis();
            IChrysalis inputChrysalis;

            using (var stream = new MemoryStream())
            {
                SerializationHelper.Serialize(chrysalis, stream);
                stream.Position = 0;
                using (var reader = XmlReader.Create(stream))
                {
                    inputChrysalis = SerializationHelper.Deserialize(reader);
                }
            }

            Assert.True(chrysalis.RootGroups.First().Equals(inputChrysalis.RootGroups.First()));
        }