예제 #1
0
        public void Button_XmlSerialize_Test()
        {
            var parent = new TestHelpers.RootElement();
            var expected = new Button(parent, AssetManager);
            var block = new TextBlock(expected, AssetManager) { Name = "Normal TextBlock" };
            expected.SetTemplate(ButtonState.Normal, block.Name);

            var stream = new MemoryStream();
            using (var xmlWriter = XmlWriter.Create(stream))
            {
                expected.WriteXml(xmlWriter);
            }

            stream.Position = 0;
            var actual = new Button(parent, AssetManager);
            using (var xmlReader = XmlReader.Create(stream))
            {
                actual.ReadXml(xmlReader);
            }

            Assert.AreEqual(block.Name, actual.GetTemplate(ButtonState.Normal).Name);
            Assert.IsNull(actual.GetTemplate(ButtonState.Hover));
        }