public void MSCPSWS_S05_TC01_Search()
        {
            // Set principal type for search.
            SPPrincipalType principalType = SPPrincipalType.SecurityGroup;

            // Generate ArrayOfSPProviderSearchArguments.
            List <SPProviderSearchArguments> arrayOfSPProviderSearchArguments = new List <SPProviderSearchArguments>();

            Site.Assume.IsNotNull(this.GenerateProviderSearchArgumentsInput_Valid(), "There should be a valid provider search arguments!");
            SPProviderSearchArguments providerSearchArguments = this.GenerateProviderSearchArgumentsInput_Valid();

            arrayOfSPProviderSearchArguments.Add(providerSearchArguments);

            Site.Assume.IsNotNull(TestSuiteBase.SearchPattern, "The search pattern should not be null!");

            // Call Search operation.
            SPProviderHierarchyTree[] responseOfSearchResult = CPSWSAdapter.Search(arrayOfSPProviderSearchArguments.ToArray(), principalType, TestSuiteBase.SearchPattern);

            Site.Assert.IsNotNull(responseOfSearchResult, "The search result MUST be not null.");
            Site.Assert.IsTrue(responseOfSearchResult.Length >= 1, "The search result MUST contain at least one claims provider.");

            // Get the input provider names list.
            ArrayOfString providerNames = new ArrayOfString();

            providerNames.AddRange(arrayOfSPProviderSearchArguments.Select(root => root.ProviderName));

            // Requirement capture condition.
            bool searchSuccess = false;

            foreach (SPProviderHierarchyTree providerTree in responseOfSearchResult)
            {
                if (providerTree.ProviderName.StartsWith(Common.GetConfigurationPropertyValue("HierarchyProviderPrefix", this.Site)))
                {
                    if (providerNames.Contains(providerTree.ProviderName))
                    {
                        searchSuccess = true;
                    }
                    else
                    {
                        // Jump over the Hierarchy Provider tree that the server sees fit to return together with the result Claims provider trees.
                        continue;
                    }
                }
                else if (providerNames.Contains(providerTree.ProviderName))
                {
                    searchSuccess = true;
                }
                else
                {
                    Site.Assert.Fail("The provider names in the search result should be contained in the provider names in the input message!");
                }
            }

            // Capture requirement 378 by matching the input provider name with the result claims provider name,
            // The search input claims provider already satisfy the condition 1 and 3 in requirement 378 in test environment configuration.
            Site.CaptureRequirementIfIsTrue(
                searchSuccess,
                378,
                @"[In Search] The protocol server MUST search across all claims providers that meet all the following criteria:
                The claims providers are associated with the Web application (1) specified in the input message.
                The claims providers are listed in the provider search arguments in the input message.
                The claims providers support search.");

            // Capture requirement 398 by matching searchPattern with the result claims provider's Nm attribute.
            Site.CaptureRequirementIfIsTrue(searchSuccess, 398, @"[In Search] searchPattern: The protocol server MUST search for the string in each claims provider.");

            // Capture requirement 404 by matching searchPattern with the result claims provider's Nm attribute.
            Site.CaptureRequirementIfIsTrue(searchSuccess, 404, @"[In SearchResponse] The protocol server MUST return one claims provider hierarchy tree for each claims provider that contains entities that match the search string.");
        }
        public void MSCPSWS_S05_TC01_Search()
        {
            // Set principal type for search.
            SPPrincipalType principalType = SPPrincipalType.SecurityGroup;

            // Generate ArrayOfSPProviderSearchArguments.
            List<SPProviderSearchArguments> arrayOfSPProviderSearchArguments = new List<SPProviderSearchArguments>();

            Site.Assume.IsNotNull(this.GenerateProviderSearchArgumentsInput_Valid(), "There should be a valid provider search arguments!");
            SPProviderSearchArguments providerSearchArguments = this.GenerateProviderSearchArgumentsInput_Valid();
            arrayOfSPProviderSearchArguments.Add(providerSearchArguments);

            Site.Assume.IsNotNull(TestSuiteBase.SearchPattern, "The search pattern should not be null!");

            // Call Search operation.
            SPProviderHierarchyTree[] responseOfSearchResult = CPSWSAdapter.Search(arrayOfSPProviderSearchArguments.ToArray(), principalType, TestSuiteBase.SearchPattern);

            Site.Assert.IsNotNull(responseOfSearchResult, "The search result MUST be not null.");
            Site.Assert.IsTrue(responseOfSearchResult.Length >= 1, "The search result MUST contain at least one claims provider.");

            // Get the input provider names list.
            ArrayOfString providerNames = new ArrayOfString();
            providerNames.AddRange(arrayOfSPProviderSearchArguments.Select(root => root.ProviderName));

            // Requirement capture condition.
            bool searchSuccess = false;
            
            foreach (SPProviderHierarchyTree providerTree in responseOfSearchResult)
            {
                if (providerTree.ProviderName.StartsWith(Common.GetConfigurationPropertyValue("HierarchyProviderPrefix", this.Site)))
                {
                    if (providerNames.Contains(providerTree.ProviderName))
                    {
                        searchSuccess = true;
                    }
                    else
                    {
                        // Jump over the Hierarchy Provider tree that the server sees fit to return together with the result Claims provider trees.
                        continue;
                    }
                }               
                else if (providerNames.Contains(providerTree.ProviderName))
                {
                    searchSuccess = true;
                }
                else 
                {
                    Site.Assert.Fail("The provider names in the search result should be contained in the provider names in the input message!");
                }
            }
            
            // Capture requirement 378 by matching the input provider name with the result claims provider name,
            // The search input claims provider already satisfy the condition 1 and 3 in requirement 378 in test environment configuration.
            Site.CaptureRequirementIfIsTrue(
                searchSuccess, 
                378, 
                @"[In Search] The protocol server MUST search across all claims providers that meet all the following criteria:
                The claims providers are associated with the Web application (1) specified in the input message.
                The claims providers are listed in the provider search arguments in the input message.
                The claims providers support search.");

            // Capture requirement 398 by matching searchPattern with the result claims provider's Nm attribute.
            Site.CaptureRequirementIfIsTrue(searchSuccess, 398, @"[In Search] searchPattern: The protocol server MUST search for the string in each claims provider.");

            // Capture requirement 404 by matching searchPattern with the result claims provider's Nm attribute.
            Site.CaptureRequirementIfIsTrue(searchSuccess, 404, @"[In SearchResponse] The protocol server MUST return one claims provider hierarchy tree for each claims provider that contains entities that match the search string.");
        }
        public void MSCPSWS_S05_TC03_SearchAll()
        {
            // Get the provider names of all the providers from the hierarchy
            ArrayOfString providerNames = new ArrayOfString();

            SPProviderHierarchyTree[] responseOfGetHierarchyAllResult = TestSuiteBase.GetAllProviders();
            providerNames.AddRange(responseOfGetHierarchyAllResult.Select(root => root.ProviderName));
            foreach (SPProviderHierarchyNode node in responseOfGetHierarchyAllResult.SelectMany(root => root.Children))
            {
                this.DepthFirstTraverse(node, ref providerNames);
            }

            // Set search principal Type.
            SPPrincipalType principalType = SPPrincipalType.SecurityGroup;

            // Get the searchPattern string as SearchAll input
            this.GenerateSearchAllInput_Valid();

            // Get max count of matched entities allowed to return for this search.
            int maxCount = Convert.ToInt32(Common.GetConfigurationPropertyValue("MaxCount", Site));

            Site.Assume.IsNotNull(TestSuiteBase.SearchPattern, "The search pattern should not be null!");

            // Search the first claims provider tree which has a child.
            SPProviderHierarchyTree[] responseOfSearchResult = CPSWSAdapter.SearchAll(providerNames, principalType, TestSuiteBase.SearchPattern, maxCount);

            // Requirement capture condition.
            bool searchAllSuccess = false;

            foreach (SPProviderHierarchyTree providerTree in responseOfSearchResult)
            {
                if (providerTree.ProviderName.StartsWith(Common.GetConfigurationPropertyValue("HierarchyProviderPrefix", this.Site)))
                {
                    if (providerNames.Contains(providerTree.ProviderName))
                    {
                        searchAllSuccess = true;
                    }
                    else
                    {
                        // Jump over the Hierarchy Provider tree that the server sees fit to return together with the result Claims provider trees.
                        continue;
                    }
                }
                else if (providerNames.Contains(providerTree.ProviderName))
                {
                    searchAllSuccess = true;
                }
                else
                {
                    Site.Assert.Fail("The provider names in the SearchAll result should be contained in the provider names in the input message!");
                }
            }

            // Capture requirement 417 by matching the input provider name with the result claims provider name,
            // The search input claims provider already satisfy the condition 1 and 3 in requirement 417 in test environment configuration.
            Site.CaptureRequirementIfIsTrue(
                searchAllSuccess,
                417,
                @"[In SearchAll] The protocol server MUST search across all claims providers that meet all the following criteria:
                The claims providers are associated with the Web application (1) specified in the input message.
                The claims providers are listed in the provider names in the input message.
                The claims providers support search.");
        }
        public void MSCPSWS_S05_TC03_SearchAll()
        {
            // Get the provider names of all the providers from the hierarchy
            ArrayOfString providerNames = new ArrayOfString();
            SPProviderHierarchyTree[] responseOfGetHierarchyAllResult = TestSuiteBase.GetAllProviders();
            providerNames.AddRange(responseOfGetHierarchyAllResult.Select(root => root.ProviderName));
            foreach (SPProviderHierarchyNode node in responseOfGetHierarchyAllResult.SelectMany(root => root.Children))
            {
                this.DepthFirstTraverse(node, ref providerNames);
            }

            // Set search principal Type.
            SPPrincipalType principalType = SPPrincipalType.SecurityGroup;

            // Get the searchPattern string as SearchAll input
            this.GenerateSearchAllInput_Valid();

            // Get max count of matched entities allowed to return for this search.
            int maxCount = Convert.ToInt32(Common.GetConfigurationPropertyValue("MaxCount", Site));

            Site.Assume.IsNotNull(TestSuiteBase.SearchPattern, "The search pattern should not be null!");

            // Search the first claims provider tree which has a child.
            SPProviderHierarchyTree[] responseOfSearchResult = CPSWSAdapter.SearchAll(providerNames, principalType, TestSuiteBase.SearchPattern, maxCount);

            // Requirement capture condition.
            bool searchAllSuccess = false;

            foreach (SPProviderHierarchyTree providerTree in responseOfSearchResult)
            {
                if (providerTree.ProviderName.StartsWith(Common.GetConfigurationPropertyValue("HierarchyProviderPrefix", this.Site)))
                {
                    if (providerNames.Contains(providerTree.ProviderName))
                    {
                        searchAllSuccess = true;
                    }
                    else
                    {
                        // Jump over the Hierarchy Provider tree that the server sees fit to return together with the result Claims provider trees.
                        continue;
                    }
                }
                else if (providerNames.Contains(providerTree.ProviderName))
                {
                    searchAllSuccess = true;
                }
                else
                {
                    Site.Assert.Fail("The provider names in the SearchAll result should be contained in the provider names in the input message!");
                }
            }

            // Capture requirement 417 by matching the input provider name with the result claims provider name,
            // The search input claims provider already satisfy the condition 1 and 3 in requirement 417 in test environment configuration.
            Site.CaptureRequirementIfIsTrue(
                searchAllSuccess, 
                417, 
                @"[In SearchAll] The protocol server MUST search across all claims providers that meet all the following criteria:
                The claims providers are associated with the Web application (1) specified in the input message.
                The claims providers are listed in the provider names in the input message.
                The claims providers support search.");
        }