public void TestMVDateTimeLessThanOrEqualsFunction() { object queryValue = "current-dateTime()"; List <object> nonMatchValue = new List <object>() { "2100-01-01T00:00:00.000", "2200-01-01T00:00:00.000" }; List <object> matchValue = new List <object>() { "2000-01-01T00:00:00.000", "2200-01-01T00:00:00.000" }; ResourceObject matchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeDateTimeMV, matchValue); ResourceObject nonMatchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeDateTimeMV, nonMatchValue); try { string expected = string.Format("/{0}[({1} <= {2})]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeDateTimeMV, queryValue); this.SubmitXpath(queryValue, expected, UnitTestHelper.AttributeDateTimeMV, ComparisonOperator.LessThanOrEquals, GroupOperator.And, matchResource); } finally { UnitTestHelper.CleanupTestResources(matchResource, nonMatchResource); } }
public void TestMVDateTimeGreaterThan() { object queryValue = "2000-01-01T00:00:00.000"; List <object> nonMatchValue = new List <object>() { "1900-01-01T00:00:00.000", "1800-01-01T00:00:00.000" }; List <object> matchValue = new List <object>() { "2100-01-01T00:00:00.000", "2200-01-01T00:00:00.000" }; ResourceObject matchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeDateTimeMV, matchValue); ResourceObject nonMatchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeDateTimeMV, nonMatchValue); try { string expected = string.Format("/{0}[({1} > '{2}')]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeDateTimeMV, queryValue); this.SubmitXpath(queryValue, expected, UnitTestHelper.AttributeDateTimeMV, ComparisonOperator.GreaterThan, GroupOperator.And, matchResource); } finally { UnitTestHelper.CleanupTestResources(matchResource, nonMatchResource); } }
public void XpathPredicateGroupNestedTest() { string testValue1 = "test1"; string testValue2 = "test2"; long testValue3 = 55L; string nonMatchValue = "test3"; XPathQuery predicate1 = new XPathQuery(UnitTestHelper.AttributeStringSV, ComparisonOperator.Equals, testValue1); XPathQuery predicate2 = new XPathQuery(UnitTestHelper.AttributeStringMV, ComparisonOperator.Equals, testValue2); XPathQuery predicate3 = new XPathQuery(UnitTestHelper.AttributeIntegerSV, ComparisonOperator.Equals, testValue3); XPathQueryGroup childGroup = new XPathQueryGroup(GroupOperator.Or, predicate1, predicate2); XPathQueryGroup group = new XPathQueryGroup(GroupOperator.And, predicate3, childGroup); string expected = string.Format("(({4} = {5}) and (({0} = '{1}') or ({2} = '{3}')))", UnitTestHelper.AttributeStringSV, testValue1, UnitTestHelper.AttributeStringMV, testValue2, UnitTestHelper.AttributeIntegerSV, testValue3); ResourceObject matchObject = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeStringSV, testValue1); ResourceObject nonMatchObject = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeStringSV, nonMatchValue); matchObject.Attributes[UnitTestHelper.AttributeIntegerSV].SetValue(testValue3); matchObject.Save(); try { this.SubmitXpath(group, expected, matchObject); } finally { UnitTestHelper.CleanupTestResources(matchObject, nonMatchObject); } }
public void TestMVStringContains() { /* * FROM https://msdn.microsoft.com/en-us/library/windows/desktop/ee652287(v=vs.100).aspx * * Given the following string: "The quick brown fox," and the contains() query on the string "u", the expectedXpath result is * that nothing is returned, since the letter "u" only appears in the middle of a string, and not immediately after a wordbreaker. * If we ran the contains() query on the string "qu", however, we would get a match, since the substring "qu" appears immediately * after a wordbreaking character. */ string queryValue = "abc"; List <string> nonMatchValue = new List <string>() { "123 def", "456 def" }; List <string> matchValue = new List <string>() { "sdf abc", "1011 ghi" }; ResourceObject matchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeStringMV, matchValue); ResourceObject nonMatchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeStringMV, nonMatchValue); try { string expected = string.Format("/{0}[(contains({1}, '{2}'))]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeStringMV, queryValue); this.SubmitXpath(queryValue, expected, UnitTestHelper.AttributeStringMV, ComparisonOperator.Contains, GroupOperator.And, matchResource); } finally { UnitTestHelper.CleanupTestResources(matchResource, nonMatchResource); } }
public void TestMVIntegerLessThanOrEquals() { object queryValue = 10; List <object> nonMatchValue = new List <object>() { 15, 20 }; List <object> matchValue = new List <object>() { 10, 20 }; ResourceObject matchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeIntegerMV, matchValue); ResourceObject nonMatchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeIntegerMV, nonMatchValue); try { string expected = string.Format("/{0}[({1} <= {2})]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeIntegerMV, queryValue); this.SubmitXpath(queryValue, expected, UnitTestHelper.AttributeIntegerMV, ComparisonOperator.LessThanOrEquals, GroupOperator.And, matchResource); } finally { UnitTestHelper.CleanupTestResources(matchResource, nonMatchResource); } }
public void TestSVStringEqualsWithSingleAndDoubleQuote() { string queryValue = "user\"'0001"; string nonMatchValue = "user0002"; string matchValue = "user\"'0001"; ResourceObject matchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeStringSV, matchValue); ResourceObject nonMatchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeStringSV, nonMatchValue); try { string expected = string.Format("/{0}[({1} = '{2}')]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeStringSV, queryValue); this.SubmitXpath(queryValue, expected, UnitTestHelper.AttributeStringSV, ComparisonOperator.Equals, GroupOperator.And, matchResource); } catch (ArgumentException) { return; } finally { UnitTestHelper.CleanupTestResources(matchResource, nonMatchResource); } Assert.Fail("The expected exception was not thrown"); }
public void TestMVStringStartsWith() { string queryValue = "y"; List <string> nonMatchValue = new List <string>() { "xuser0004", "xuser0003" }; List <string> matchValue = new List <string>() { "yuser0002", "yuser0001" }; ResourceObject matchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeStringMV, matchValue); ResourceObject nonMatchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeStringMV, nonMatchValue); try { string expected = string.Format("/{0}[(starts-with({1}, '{2}'))]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeStringMV, queryValue); this.SubmitXpath(queryValue, expected, UnitTestHelper.AttributeStringMV, ComparisonOperator.StartsWith, GroupOperator.And, matchResource); } finally { UnitTestHelper.CleanupTestResources(matchResource, nonMatchResource); } }
public void TestMVStringNotEquals() { string queryValue = "user0001"; List <string> nonMatchValue = new List <string>() { "user0001", "user0002" }; List <string> matchValue = new List <string>() { "user0003", "user0004" }; ResourceObject matchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeStringMV, matchValue); ResourceObject nonMatchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeStringMV, nonMatchValue); try { string expected = string.Format("/{0}[(not({1} = '{2}'))]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeStringMV, queryValue, matchResource); this.SubmitXpath(queryValue, expected, UnitTestHelper.AttributeStringMV, ComparisonOperator.NotEquals, GroupOperator.And, matchResource); } finally { UnitTestHelper.CleanupTestResources(matchResource, nonMatchResource); } }
public void TestMVIntegerNotEquals() { object queryValue = 1; List <long> nonMatchValue = new List <long>() { 1, 3 }; List <long> matchValue = new List <long>() { 3, 4 }; ResourceObject matchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeIntegerMV, matchValue); ResourceObject nonMatchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeIntegerMV, nonMatchValue); try { string expected = string.Format("/{0}[(not({1} = {2}))]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeIntegerMV, queryValue, matchResource); this.SubmitXpath(queryValue, expected, UnitTestHelper.AttributeIntegerMV, ComparisonOperator.NotEquals, GroupOperator.And, matchResource); } finally { UnitTestHelper.CleanupTestResources(matchResource, nonMatchResource); } }
public void TestSVReferenceIsNotPresent() { object queryValue = null; ResourceObject matchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeReferenceSV, null); ResourceObject nonMatchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeReferenceSV, matchResource.ObjectID); try { string expected = string.Format("/{0}[(not({1} = /*))]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeReferenceSV, XPathQuery.MaxDate); this.SubmitXpath(queryValue, expected, UnitTestHelper.AttributeReferenceSV, ComparisonOperator.IsNotPresent, GroupOperator.And, matchResource); } finally { UnitTestHelper.CleanupTestResources(matchResource, nonMatchResource); } }
public void TestSVReferenceNotEquals() { ResourceObject matchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeReferenceSV, null); ResourceObject nonMatchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeReferenceSV, matchResource.ObjectID); object queryValue = matchResource.ObjectID.Value; try { string expected = string.Format("/{0}[(not({1} = '{2}'))]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeReferenceSV, queryValue, matchResource); this.SubmitXpath(queryValue, expected, UnitTestHelper.AttributeReferenceSV, ComparisonOperator.NotEquals, GroupOperator.And, matchResource); } finally { UnitTestHelper.CleanupTestResources(matchResource, nonMatchResource); } }
public void TestSVIntegerIsPresent() { object queryValue = null; object nonMatchValue = null; object matchValue = 1; ResourceObject matchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeIntegerSV, matchValue); ResourceObject nonMatchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeIntegerSV, nonMatchValue); try { string expected = string.Format("/{0}[({1} <= {2})]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeIntegerSV, XPathQuery.MaxLong); this.SubmitXpath(queryValue, expected, UnitTestHelper.AttributeIntegerSV, ComparisonOperator.IsPresent, GroupOperator.And, matchResource); } finally { UnitTestHelper.CleanupTestResources(matchResource, nonMatchResource); } }
public void TestSVStringEqualsWithDoubleQuote() { string queryValue = "user\"0001"; string nonMatchValue = "user0002"; string matchValue = "user\"0001"; ResourceObject matchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeStringSV, matchValue); ResourceObject nonMatchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeStringSV, nonMatchValue); try { string expected = string.Format("/{0}[({1} = '{2}')]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeStringSV, queryValue); this.SubmitXpath(queryValue, expected, UnitTestHelper.AttributeStringSV, ComparisonOperator.Equals, GroupOperator.And, matchResource); } finally { UnitTestHelper.CleanupTestResources(matchResource, nonMatchResource); } }
public void TestSVDateTimeLessThanOrEquals() { object queryValue = "2000-01-01T00:00:00.000"; object nonMatchValue = "2100-01-01T00:00:00.000"; object matchValue = "2000-01-01T00:00:00.000"; ResourceObject matchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeDateTimeSV, matchValue); ResourceObject nonMatchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeDateTimeSV, nonMatchValue); try { string expected = string.Format("/{0}[({1} <= '{2}')]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeDateTimeSV, queryValue); this.SubmitXpath(queryValue, expected, UnitTestHelper.AttributeDateTimeSV, ComparisonOperator.LessThanOrEquals, GroupOperator.And, matchResource); } finally { UnitTestHelper.CleanupTestResources(matchResource, nonMatchResource); } }
public void TestSVStringIsNotPresent() { string queryValue = null; string nonMatchValue = "user0001"; string matchValue = null; ResourceObject matchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeStringSV, matchValue); ResourceObject nonMatchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeStringSV, nonMatchValue); try { string expected = string.Format("/{0}[(not(starts-with({1}, '%')))]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeStringSV, queryValue); this.SubmitXpath(queryValue, expected, UnitTestHelper.AttributeStringSV, ComparisonOperator.IsNotPresent, GroupOperator.And, matchResource); } finally { UnitTestHelper.CleanupTestResources(matchResource, nonMatchResource); } }
public void TestSVIntegerLessThan() { object queryValue = 10; object nonMatchValue = 15; object matchValue = 9; ResourceObject matchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeIntegerSV, matchValue); ResourceObject nonMatchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeIntegerSV, nonMatchValue); try { string expected = string.Format("/{0}[({1} < {2})]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeIntegerSV, queryValue); this.SubmitXpath(queryValue, expected, UnitTestHelper.AttributeIntegerSV, ComparisonOperator.LessThan, GroupOperator.And, matchResource); } finally { UnitTestHelper.CleanupTestResources(matchResource, nonMatchResource); } }
public void TestSVDateTimeIsNotPresent() { object queryValue = null; object nonMatchValue = "2000-01-01T00:00:00.000"; object matchValue = null; ResourceObject matchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeDateTimeSV, matchValue); ResourceObject nonMatchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeDateTimeSV, nonMatchValue); try { string expected = string.Format("/{0}[(not({1} <= '{2}'))]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeDateTimeSV, XPathQuery.MaxDate); this.SubmitXpath(queryValue, expected, UnitTestHelper.AttributeDateTimeSV, ComparisonOperator.IsNotPresent, GroupOperator.And, matchResource); } finally { UnitTestHelper.CleanupTestResources(matchResource, nonMatchResource); } }
public void TestSVBooleanIsPresent() { object queryValue = null; object nonMatchValue = null; object matchValue = true; ResourceObject matchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeBooleanSV, matchValue); ResourceObject nonMatchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeBooleanSV, nonMatchValue); try { string expected = string.Format("/{0}[(({1} = true) or ({1} = false))]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeBooleanSV, XPathQuery.MaxDate); this.SubmitXpath(queryValue, expected, UnitTestHelper.AttributeBooleanSV, ComparisonOperator.IsPresent, GroupOperator.And, matchResource); } finally { UnitTestHelper.CleanupTestResources(matchResource, nonMatchResource); } }
public void TestSVDateTimeGreaterThanFunction() { object queryValue = "current-dateTime()"; object nonMatchValue = "2000-01-01T00:00:00.000"; object matchValue = "3000-01-01T00:00:00.000"; ResourceObject matchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeDateTimeSV, matchValue); ResourceObject nonMatchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeDateTimeSV, nonMatchValue); try { string expected = string.Format("/{0}[({1} > {2})]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeDateTimeSV, queryValue); this.SubmitXpath(queryValue, expected, UnitTestHelper.AttributeDateTimeSV, ComparisonOperator.GreaterThan, GroupOperator.And, matchResource); } finally { UnitTestHelper.CleanupTestResources(matchResource, nonMatchResource); } }
public void TestSVBooleanNotEquals() { object queryValue = true; object nonMatchValue = true; object matchValue = false; ResourceObject matchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeBooleanSV, matchValue); ResourceObject nonMatchResource = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeBooleanSV, nonMatchValue); try { string expected = string.Format("/{0}[(not({1} = {2}))]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeBooleanSV, queryValue, matchResource); this.SubmitXpath(queryValue, expected, UnitTestHelper.AttributeBooleanSV, ComparisonOperator.NotEquals, GroupOperator.And, matchResource); } finally { UnitTestHelper.CleanupTestResources(matchResource, nonMatchResource); } }
public void XpathExpressionDereferencedTest() { string testValue1 = "test1"; XPathQuery predicate1 = new XPathQuery(UnitTestHelper.AttributeStringSV, ComparisonOperator.Equals, testValue1); XPathDereferencedExpression expression = new XPathDereferencedExpression(UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeReferenceSV, predicate1); string expected = string.Format("/{0}[({1} = '{2}')]/{3}", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeStringSV, testValue1, UnitTestHelper.AttributeReferenceSV); ResourceObject parentObject1 = UnitTestHelper.CreateTestResource(); ResourceObject filterTargetObject = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeStringSV, testValue1, UnitTestHelper.AttributeReferenceSV, parentObject1); try { this.SubmitXpath(expression, expected, parentObject1); } finally { UnitTestHelper.CleanupTestResources(filterTargetObject, parentObject1); } }
public void XpathPredicateGroupSingleValueTest() { string testValue1 = "test1"; string nonMatchValue = "test3"; XPathQuery predicate1 = new XPathQuery(UnitTestHelper.AttributeStringSV, ComparisonOperator.Equals, testValue1); XPathQueryGroup group = new XPathQueryGroup(GroupOperator.And, predicate1); string expected = string.Format("({0} = '{1}')", UnitTestHelper.AttributeStringSV, testValue1); ResourceObject matchObject = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeStringSV, testValue1); ResourceObject nonMatchObject = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeStringSV, nonMatchValue); try { this.SubmitXpath(group, expected, matchObject); } finally { UnitTestHelper.CleanupTestResources(matchObject, nonMatchObject); } }
public void XpathExpressionNestedTest() { string testValue1 = "test1"; XPathQuery predicate1 = new XPathQuery(UnitTestHelper.AttributeStringSV, ComparisonOperator.Equals, testValue1); XPathExpression childExpression = new XPathExpression(UnitTestHelper.ObjectTypeUnitTestObjectName, predicate1); XPathQuery predicate2 = new XPathQuery(UnitTestHelper.AttributeReferenceSV, ComparisonOperator.Equals, childExpression); XPathExpression expression = new XPathExpression(UnitTestHelper.ObjectTypeUnitTestObjectName, predicate2); string expected = string.Format("/{0}[({1} = /{0}[({2} = '{3}')])]", UnitTestHelper.ObjectTypeUnitTestObjectName, UnitTestHelper.AttributeReferenceSV, UnitTestHelper.AttributeStringSV, testValue1); ResourceObject filterTargetObject = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeStringSV, testValue1); ResourceObject childObject1 = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeReferenceSV, filterTargetObject.ObjectID); ResourceObject childObject2 = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeReferenceSV, filterTargetObject.ObjectID); ResourceObject childObject3 = UnitTestHelper.CreateTestResource(UnitTestHelper.AttributeReferenceSV, filterTargetObject.ObjectID); try { this.SubmitXpath(expression, expected, childObject1, childObject2, childObject3); } finally { UnitTestHelper.CleanupTestResources(filterTargetObject, childObject1, childObject2, childObject3); } }