Exemplo n.º 1
0
 public void Elements_currentNodeEqualsValue()
 {
     XPathString path = new XPathString("[.='Mike']");
     XPath_Bracket target = new XPath_Bracket(path);
     IEnumerable<XElement> elements = root.Descendants();
     var expected = root.Descendants()
         .Where(xe => xe.Value == "Mike").ToArray();
     var actual = target.Elements(elements).ToArray();
     CollectionAssert.AreEqual(expected, actual);
 }
Exemplo n.º 2
0
 public void XPath_Bracket_Constructor()
 {
     XPathString path = new XPathString("[.='Mike']");
     XPath_Bracket target = new XPath_Bracket(path);
     Assert.AreEqual(target.Parts.Length, 1);
     var part = target.Parts[0];
     Assert.AreEqual(part.ElementAt, false);
     Assert.AreEqual(part.Equal, true);
     Assert.AreEqual(part.Function, null);
     Assert.AreEqual(part.GreaterThan, false);
     Assert.AreEqual(part.GreaterThanOrEqual, false);
     Assert.AreEqual(part.IsValueAttribute, false);
     Assert.AreEqual(part.Key, ".");
     Assert.AreEqual(part.KVP, true);
     Assert.AreEqual(part.LessThan, false);
     Assert.AreEqual(part.LessThanOrEqual, false);
     Assert.AreEqual(part.NotEqual, false);
     Assert.AreEqual(part.Value, "Mike");
 }
Exemplo n.º 3
0
 public void XPath_Part_KVP_GTEqualR()
 {
     XPathString path = new XPathString("[{0}>=to]", 0);
     XPath_Bracket target = new XPath_Bracket(path);
     Assert.AreEqual(target.Parts.Length, 1);
     var part = target.Parts[0]; // XPath_Part becomes "to < {0}"
     Assert.AreEqual(part.ElementAt, false);
     Assert.AreEqual(part.IsValueAttribute, false);
     Assert.AreEqual(part.KVP, true);
     Assert.AreEqual(null, part.Function);
     Assert.AreEqual(part.Equal, false);
     Assert.AreEqual(part.GreaterThan, false);
     Assert.AreEqual(part.GreaterThanOrEqual, false);
     Assert.AreEqual(part.LessThan, true);
     Assert.AreEqual(part.LessThanOrEqual, false);
     Assert.AreEqual(part.NotEqual, false);
     Assert.AreEqual(part.Key, "to");
     Assert.AreEqual(part.Value, 0);
 }
Exemplo n.º 4
0
 public void XPath_Bracket_Constructor2()
 {
     XPathString path = new XPathString("[min(Value2/Value, {0})]", 0);
     XPath_Bracket target = new XPath_Bracket(path);
     Assert.AreEqual(target.Parts.Length, 1);
     var part = target.Parts[0];
     Assert.AreEqual(part.ElementAt, false);
     Assert.AreEqual(part.Equal, true);
     Assert.AreNotEqual(null, part.Function);
     Assert.IsInstanceOfType(part.Function, typeof(MinMax));
     Assert.AreEqual(part.GreaterThan, false);
     Assert.AreEqual(part.GreaterThanOrEqual, false);
     Assert.AreEqual(part.IsValueAttribute, false);
     Assert.AreEqual(part.Key, "Value2/Value");
     Assert.AreEqual(part.KVP, false);
     Assert.AreEqual(part.LessThan, false);
     Assert.AreEqual(part.LessThanOrEqual, false);
     Assert.AreEqual(part.NotEqual, false);
     Assert.AreEqual(part.Value, 0);
 }
Exemplo n.º 5
0
 public void XPath_Part_KVP_Right()
 {
     /*
      * Swaps the expression to be [@to >= {0}]
      * So we compare for > and >=
      */
     XPathString path = new XPathString("[{0} < @to]", 0);
     XPath_Bracket target = new XPath_Bracket(path);
     Assert.AreEqual(target.Parts.Length, 1);
     var part = target.Parts[0]; // XPath_Part
     Assert.AreEqual(part.ElementAt, false);
     Assert.AreEqual(null, part.Function);
     Assert.AreEqual(part.IsValueAttribute, true);
     Assert.AreEqual(part.KVP, true);
     Assert.AreEqual(part.Equal, true);
     Assert.AreEqual(part.GreaterThan, true);
     Assert.AreEqual(part.GreaterThanOrEqual, true);
     Assert.AreEqual(part.LessThan, false);
     Assert.AreEqual(part.LessThanOrEqual, false);
     Assert.AreEqual(part.NotEqual, false);
     Assert.AreEqual(part.Key, "to");
     Assert.AreEqual(part.Value, 0);
 }