public void ShouldFindPropertiesWithElementsThatArePrivate() { TypeBrowser.ElementInfo result = this.browser.FindElement( new XmlComponent(null, "Base.Private", null)); Assert.That(result, Is.Not.Null); }
public void ShouldIgnorePropertiesWithElements() { TypeBrowser.ElementInfo result = this.browser.FindAttribute( new XmlComponent(null, "Derived.Public", null)); Assert.That(result, Is.Null); }
public void ShouldFindPropertiesWithElementsByName() { TypeBrowser.ElementInfo result = this.browser.FindElement( new XmlComponent(null, "Derived.Public", null)); Assert.That(result, Is.Not.Null); }
public void ShouldIgnoreReadOnlyProperties() { TypeBrowser.ElementInfo result = this.browser.FindElement( new XmlComponent(null, "Derived.ReadOnly", null)); Assert.That(result, Is.Null); }
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")); }
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)); }
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" })); }
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" })); }
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)); }
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); } }