Пример #1
0
        public void Parse_VariableWithNegativeIntIndexer_ExpectedResult()
        {
            OPathParseResult parseResult = OPathParser.Parse("Variable1[-1] = 1");

            Assert.AreEqual("$Var1 = 1", parseResult.GetXPath(), "parseResult.GetXPath()");
            Assert.AreEqual(1, parseResult.GetVariables().Length, "parseResult.GetVariables().Length");

            OPathVariable variable1 = GetVariable("Var1", parseResult.GetVariables());

            Assert.AreEqual("Variable1", variable1.Name, "variable1.Name");
            Assert.AreEqual("[-1]", variable1.GetOPath(), "variable1.GetOPath()");

            Assert.AreEqual(1, variable1.OPathParts.Length, "variable1.OPathParts.Length");
            AssertVariableIntIndexPart(variable1, 0, -1);
        }
Пример #2
0
        public void Parse_VariableWithIntIndexersWithWhitespace_ExpectedResult()
        {
            OPathParseResult parseResult = OPathParser.Parse("Variable1 [ 1 ] [ 2 ] = 1");

            Assert.AreEqual("$Var1 = 1", parseResult.GetXPath(), "parseResult.GetXPath()");
            Assert.AreEqual(1, parseResult.GetVariables().Length, "parseResult.GetVariables().Length");

            OPathVariable variable1 = GetVariable("Var1", parseResult.GetVariables());

            Assert.AreEqual("Variable1", variable1.Name, "variable1.Name");
            Assert.AreEqual("[1][2]", variable1.GetOPath(), "variable1.GetOPath()");

            Assert.AreEqual(2, variable1.OPathParts.Length, "variable1.OPathParts.Length");
            AssertVariableIntIndexPart(variable1, 0, 1);
            AssertVariableIntIndexPart(variable1, 1, 2);
        }