Esempio n. 1
0
        public void XamlLoadKeyElementTest()
        {
            string text = @"
            <ResourceDictionary xmlns='http://schemas.microsoft.com/winfx/2006/xaml/presentation' xmlns:x='http://schemas.microsoft.com/winfx/2006/xaml' xmlns:test='clr-namespace:Granular.Presentation.Tests.Markup;assembly=Granular.Presentation.Tests'>
                <test:LoaderTestElement Value1='1' Value2='2'>
                    <x:Key>
                        <test:LoaderTestElement Value1='3' Value2='4'/>
                    </x:Key>
                </test:LoaderTestElement>
            </ResourceDictionary>";

            XamlElement        rootElement = XamlParser.Parse(text);
            ResourceDictionary dictionary  = XamlLoader.Load(rootElement) as ResourceDictionary;

            Assert.IsNotNull(dictionary);
            Assert.AreEqual(1, dictionary.Count);

            Assert.AreEqual(1, ((LoaderTestElement)dictionary.GetValues().First()).Value1);
            Assert.AreEqual(2, ((LoaderTestElement)dictionary.GetValues().First()).Value2);

            Assert.AreEqual(3, ((LoaderTestElement)dictionary.GetKeys().First()).Value1);
            Assert.AreEqual(4, ((LoaderTestElement)dictionary.GetKeys().First()).Value2);
        }