コード例 #1
0
        private string GetQueryString()
        {
            XPathExpression expression = this.XPath as XPathExpression;

            if (expression != null)
            {
                return(expression.ToString(false));
            }

            PSObject wrappedObject = this.XPath as PSObject;

            if (wrappedObject != null)
            {
                expression = wrappedObject.BaseObject as XPathExpression;

                if (expression != null)
                {
                    return(expression.ToString(false));
                }

                throw new ArgumentException("The XPath parameter must be a string or XPathExpression object");
            }

            if (!(this.XPath is string))
            {
                throw new ArgumentException("The XPath parameter must be a string or XPathExpression object");
            }

            return((string)this.XPath);
        }
コード例 #2
0
        private void SubmitXpath(XPathExpression expression, string expectedXpath, params ResourceObject[] matchResources)
        {
            Assert.AreEqual(expectedXpath, expression.ToString());

            ISearchResultCollection results = client.GetResources(expression.ToString());

            if (results.Count == 0)
            {
                if (matchResources != null && matchResources.Length > 0)
                {
                    Assert.Fail("The query returned no results");
                }
            }

            if (matchResources == null || matchResources.Length == 0)
            {
                Assert.Fail("The query returned results where none were expectedXpath");
            }

            if (results.Count != matchResources.Length)
            {
                Assert.Fail("The query returned an unexpected number of results. Expected {0}, Actual {1}", matchResources.Length, results.Count);
            }

            if (!results.All(t => matchResources.Any(u => u.ObjectID == t.ObjectID)))
            {
                Assert.Fail("The query did not return the correct results");
            }
        }
        private void SubmitXpath(XPathQueryGroup group, string expectedXpath, params ResourceObject[] matchResources)
        {
            Assert.AreEqual(expectedXpath, group.ToString());

            XPathExpression expression = new XPathExpression(UnitTestHelper.ObjectTypeUnitTestObjectName, group);

            ISearchResultCollection results = client.GetResources(expression.ToString());

            if (results.Count == 0)
            {
                if (matchResources != null && matchResources.Length > 0)
                {
                    Assert.Fail("The query returned no results");
                }
            }

            if (matchResources == null || matchResources.Length == 0)
            {
                Assert.Fail("The query returned results where none were expectedXpath");
            }

            if (results.Count != matchResources.Length)
            {
                Assert.Fail("The query returned an unexpected number of results");
            }

            if (!results.All(t => matchResources.Any(u => u.ObjectID == t.ObjectID)))
            {
                Assert.Fail("The query did not return the correct results");
            }
        }
コード例 #4
0
        private string GetRequestXPath(DateTime LastImport)
        {
            List <XPathQuery> queries = new List <XPathQuery>();

            if (LastImport == null)
            {
                LastImport = DateTime.MinValue;
            }
            else if (LastImport == DateTime.MinValue)
            {
                LastImport = DateTime.Now;
            }

            queries.Add(new XPathQuery("msidmCompletedTime", ComparisonOperator.GreaterThan, LastImport));
            queries.Add(new XPathQuery("RequestStatus", ComparisonOperator.Equals, "Completed"));

            if (RMObserverSetting.ChangeMode == ChangeModeType.My)
            {
                if (requestor == null)
                {
                    string filter = string.Format("/Person[AccountName = '{0}' and Domain = '{1}']",
                                                  Environment.UserName,
                                                  Environment.UserDomainName);

                    ResourceObject identity = RmcWrapper.Client.GetResources(filter).First();
                    requestor = identity.ObjectID.Value;
                }
                queries.Add(new XPathQuery("Creator", ComparisonOperator.Equals, requestor));
            }

            XPathQueryGroup xPathGroup = new XPathQueryGroup(GroupOperator.And, queries);
            XPathExpression expression = new XPathExpression("Request", xPathGroup);

            return(expression.ToString());
        }
コード例 #5
0
ファイル: XPathConditional.cs プロジェクト: ryanbehr/csrosa
 public String ToString()
 {
     return("xpath[" + expr.ToString() + "]");
 }