Ejemplo n.º 1
0
        public void PropertyPathGetValueTest()
        {
            PropertyPathTestElement child2 = new PropertyPathTestElement { Value = 1 };
            PropertyPathTestElement child1 = new PropertyPathTestElement { Child = child2, Children = new TestCollection<PropertyPathTestElement> { child2 } };
            PropertyPathTestElement root = new PropertyPathTestElement { Child = child1, Children = new TestCollection<PropertyPathTestElement> { child1, child2 } };

            XamlNamespaces namespaces = new XamlNamespaces("clr-namespace:Granular.Presentation.Tests;assembly=Granular.Presentation.Tests");

            object value;

            Assert.IsTrue(PropertyPath.Parse("Value").TryGetValue(child2, out value));
            Assert.AreEqual(child2.Value, value);

            Assert.IsTrue(PropertyPath.Parse("[2, 3]").TryGetValue(child2, out value));
            Assert.AreEqual(child2.Value * 2 * 3, value);

            Assert.IsTrue(PropertyPath.Parse("Child.Child.Value").TryGetValue(root, out value));
            Assert.AreEqual(child2.Value, value);

            Assert.IsTrue(PropertyPath.Parse("Child.(PropertyPathTestElement.Child).Value", namespaces).TryGetValue(root, out value));
            Assert.AreEqual(child2.Value, value);

            Assert.IsTrue(PropertyPath.Parse("Children[1].Value").TryGetValue(root, out value));
            Assert.AreEqual(child2.Value, value);

            Assert.IsTrue(PropertyPath.Parse("(PropertyPathTestElement.Children)[1].Value", namespaces).TryGetValue(root, out value));
            Assert.AreEqual(child2.Value, value);
        }
Ejemplo n.º 2
0
        public void PropertyPathGetValueTest()
        {
            PropertyPathTestElement child2 = new PropertyPathTestElement {
                Value = 1
            };
            PropertyPathTestElement child1 = new PropertyPathTestElement {
                Child = child2, Children = new TestCollection <PropertyPathTestElement> {
                    child2
                }
            };
            PropertyPathTestElement root = new PropertyPathTestElement {
                Child = child1, Children = new TestCollection <PropertyPathTestElement> {
                    child1, child2
                }
            };

            XamlNamespaces namespaces = new XamlNamespaces("clr-namespace:Granular.Presentation.Tests;assembly=Granular.Presentation.Tests");

            object value;

            Assert.IsTrue(PropertyPath.Parse("Value").TryGetValue(child2, out value));
            Assert.AreEqual(child2.Value, value);

            Assert.IsTrue(PropertyPath.Parse("[2, 3]").TryGetValue(child2, out value));
            Assert.AreEqual(child2.Value * 2 * 3, value);

            Assert.IsTrue(PropertyPath.Parse("Child.Child.Value").TryGetValue(root, out value));
            Assert.AreEqual(child2.Value, value);

            Assert.IsTrue(PropertyPath.Parse("Child.(PropertyPathTestElement.Child).Value", namespaces).TryGetValue(root, out value));
            Assert.AreEqual(child2.Value, value);

            Assert.IsTrue(PropertyPath.Parse("Children[1].Value").TryGetValue(root, out value));
            Assert.AreEqual(child2.Value, value);

            Assert.IsTrue(PropertyPath.Parse("(PropertyPathTestElement.Children)[1].Value", namespaces).TryGetValue(root, out value));
            Assert.AreEqual(child2.Value, value);
        }