public void singleAttribute() { XPathContext ctx = new XPathContext(); ctx.SetChildren(Linqy.Singleton(new Element("foo"))); ctx.NavigateToChild(0); ctx.AddAttribute(new XmlQualifiedName("bar")); ctx.NavigateToAttribute(new XmlQualifiedName("bar")); Assert.AreEqual("/foo[1]/@bar", ctx.XPath); Assert.AreEqual("/foo[1]", ctx.ParentXPath); }
static void Main(string[] args) { var inputs = new Dictionary <int, string>() { { 2, "second" }, { 3, "Fizz" }, { 5, "Buzz" }, { 6, "Sixth" } }; Console.WriteLine("Vanilla:"); Console.WriteLine(); Vanilla.FizzBuzz(inputs, Console.Out); Console.WriteLine(); Console.WriteLine("Linq-y:"); Console.WriteLine(); Linqy.FizzBuzz(inputs, Console.Out); Console.ReadLine(); }
public void AttributesAndNs() { Dictionary <string, string> m = new Dictionary <string, string>(); m["bar"] = "urn:foo:bar"; XPathContext ctx = new XPathContext(m); ctx.SetChildren(Linqy.Singleton(new Element("foo", "urn:foo:bar"))); ctx.NavigateToChild(0); List <XmlQualifiedName> l = new List <XmlQualifiedName>(); l.Add(new XmlQualifiedName("baz")); l.Add(new XmlQualifiedName("baz", "urn:foo:bar")); ctx.AddAttributes(l); ctx.NavigateToAttribute(new XmlQualifiedName("baz")); Assert.AreEqual("/bar:foo[1]/@baz", ctx.XPath); Assert.AreEqual("/bar:foo[1]", ctx.ParentXPath); ctx.NavigateToParent(); ctx.NavigateToAttribute(new XmlQualifiedName("baz", "urn:foo:bar")); Assert.AreEqual("/bar:foo[1]/@bar:baz", ctx.XPath); Assert.AreEqual("/bar:foo[1]", ctx.ParentXPath); ctx.NavigateToParent(); }