Ejemplo n.º 1
0
            public void ShouldFindPropertiesWithElementsThatArePrivate()
            {
                TypeBrowser.ElementInfo result = this.browser.FindElement(
                    new XmlComponent(null, "Base.Private", null));

                Assert.That(result, Is.Not.Null);
            }
Ejemplo n.º 2
0
            public void ShouldIgnorePropertiesWithElements()
            {
                TypeBrowser.ElementInfo result = this.browser.FindAttribute(
                    new XmlComponent(null, "Derived.Public", null));

                Assert.That(result, Is.Null);
            }
Ejemplo n.º 3
0
            public void ShouldFindPropertiesWithElementsByName()
            {
                TypeBrowser.ElementInfo result = this.browser.FindElement(
                    new XmlComponent(null, "Derived.Public", null));

                Assert.That(result, Is.Not.Null);
            }
Ejemplo n.º 4
0
            public void ShouldIgnoreReadOnlyProperties()
            {
                TypeBrowser.ElementInfo result = this.browser.FindElement(
                    new XmlComponent(null, "Derived.ReadOnly", null));

                Assert.That(result, Is.Null);
            }
Ejemplo n.º 5
0
            public void ShouldFindPropertiesWithNamespaces()
            {
                TypeBrowser.ElementInfo noNamespace = this.browser.FindElement(
                    new XmlComponent(null, "Derived.Public", null));

                TypeBrowser.ElementInfo withNamespace = this.browser.FindElement(
                    new XmlComponent(null, "Derived.Public", "ns"));

                Assert.That(noNamespace.Component.Namespace, Is.Empty);
                Assert.That(withNamespace.Component.Namespace, Is.EqualTo("ns"));
            }
Ejemplo n.º 6
0
            public void ShouldSetThePropertyValue()
            {
                var instance = new DerivedClass();

                TypeBrowser.ElementInfo info = this.browser.FindAttribute(
                    new XmlComponent(null, "Derived.Attribute", null));

                info.SetValue(instance, 123);

                Assert.That(instance.DAttribute, Is.EqualTo(123));
            }
Ejemplo n.º 7
0
            public void ShouldSetViaTheAddMethodForIEnumerableValues()
            {
                var instance = new DerivedClass();

                TypeBrowser.ElementInfo info = this.browser.FindElement(
                    new XmlComponent(null, "Derived.DCollection", null));

                info.SetValue(instance, "test");

                Assert.That(instance.DCollection, Is.EqualTo(new[] { "test" }));
            }
Ejemplo n.º 8
0
            public void ShouldGetIEnumerableValues()
            {
                var instance = new DerivedClass();

                TypeBrowser.ElementInfo info = this.browser.FindElement(
                    new XmlComponent(null, "Derived.DCollection", null));

                instance.AddString("test");
                object result = info.GetValue(instance);

                Assert.That(result, Is.EqualTo(new[] { "test" }));
            }
Ejemplo n.º 9
0
            public void ShouldGetThePropertyValue()
            {
                var instance = new DerivedClass {
                    DAttribute = 123
                };

                TypeBrowser.ElementInfo info = this.browser.FindAttribute(
                    new XmlComponent(null, "Derived.Attribute", null));

                object result = info.GetValue(instance);

                Assert.That(result, Is.EqualTo(123));
            }
Ejemplo n.º 10
0
        private static void MergeValue(TypeBrowser.ElementInfo element, object target, object value)
        {
            // First check if it's an element and merge any existing info.
            if (value is Element sourceElement)
            {
                value = MergeElements(sourceElement, element.GetValue(target) as Element);
            }
            else if (value != null)
            {
                value = CreateClone(value);
            }

            if (value != null)
            {
                element.SetValue(target, value);
            }
        }