public void NavigateMixed() { var source = new TestSource2(); var nav = new NavigableNavigator(source); nav.MoveToRoot(); nav.MoveToFirstChild(); Assert.AreEqual("root", nav.Name); nav.MoveToFirstChild(); Assert.AreEqual("type1", nav.Name); // our content nav.MoveToFirstChild(); Assert.AreEqual("prop1", nav.Name); // our property Assert.AreEqual(XPathNodeType.Element, nav.NodeType); nav.MoveToFirstChild(); // "<data><item1>poo</item1><item2 xx=\"33\" /><item2 xx=\"34\" /></data>" Assert.AreEqual(XPathNodeType.Element, nav.NodeType); Assert.AreEqual("data", nav.Name); nav.MoveToFirstChild(); Assert.AreEqual(XPathNodeType.Element, nav.NodeType); Assert.AreEqual("item1", nav.Name); nav.MoveToNext(); Assert.AreEqual(XPathNodeType.Element, nav.NodeType); Assert.AreEqual("item2", nav.Name); nav.MoveToParent(); Assert.AreEqual(XPathNodeType.Element, nav.NodeType); Assert.AreEqual("data", nav.Name); nav.MoveToParent(); Assert.AreEqual(XPathNodeType.Element, nav.NodeType); Assert.AreEqual("prop1", nav.Name); }
public TestProxy8(TestSource2 source) { this.Source = source; this.valueAdapter = this.CreatePropertyAdapter( nameof(this.Value), () => this.Source.Value, _ => this.Source.Value = _ ); }
public void ShouldNotThrowWhenTheProblemPropNameIsIgnored() { var source = new TestSource2(); var target = new TestTarget2(); Action action = () => this.utilitiesService.UpdatePropertiesReflection(source, target, new string[] { "Collection" }); action.Should().NotThrow(); }
public void ShouldThrowIfPropertiesAreDifferentTypes() { var source = new TestSource2(); var target = new TestTarget2(); Action action = () => this.utilitiesService.UpdatePropertiesReflection(source, target); action.Should().Throw <Exception>(); }
public void QueryMixedWithVariables() { var source = new TestSource2(); var nav = new NavigableNavigator(source); var iterator = nav.Select("//item2 [@xx=$var]", new XPathVariable("var", "33")); Assert.AreEqual(1, iterator.Count); iterator.MoveNext(); Assert.AreEqual("item2", iterator.Current.Name); }
public void OuterXmlMixed() { var source = new TestSource2(); var nav = new NavigableNavigator(source); nav.MoveToRoot(); const string outerXml = @"<root id=""-1""> <type1 id=""1""> <prop1> <data> <item1>poo</item1> <item2 xx=""33"" /> <item2 xx=""34"" /> </data> </prop1> </type1> </root>"; Assert.AreEqual(outerXml.Lf(), nav.OuterXml.Lf()); }
public void QueryMixed() { var source = new TestSource2(); var nav = new NavigableNavigator(source); XPathDocument doc = XmlHelper.CreateXPathDocument("<data><item1>poo</item1><item2 xx=\"33\" /><item2 xx=\"34\" /></data>"); XPathNavigator docNav = doc.CreateNavigator(); XPathNodeIterator docIter = docNav.Select("//item2 [@xx=33]"); Assert.AreEqual(1, docIter.Count); Assert.AreEqual(string.Empty, docIter.Current.Name); docIter.MoveNext(); Assert.AreEqual("item2", docIter.Current.Name); XPathNodeIterator iterator = nav.Select("//item2 [@xx=33]"); Assert.AreEqual(1, iterator.Count); Assert.AreEqual(string.Empty, iterator.Current.Name); iterator.MoveNext(); Assert.AreEqual("item2", iterator.Current.Name); }