public async Task TestAllSearchResources(string SourceUrl)
        {
            SourceRepository repo     = GetSourceRepository(SourceUrl);
            UISearchResource resource = await repo.GetResource <UISearchResource>();

            //Check if we are able to obtain a resource
            Assert.True(resource != null);
            //check if the resource is of type IVsSearch.
            SearchFilter         filter  = new SearchFilter(); //create a dummy filter.
            List <FrameworkName> fxNames = new List <FrameworkName>();

            fxNames.Add(new FrameworkName(".NET Framework, Version=4.0"));
            filter.SupportedFrameworks = fxNames.Select(e => e.ToString());
            string SearchTerm = "Elmah";
            IEnumerable <UISearchMetadata> uiSearchResults = await resource.Search(SearchTerm, filter, 0, 100, new System.Threading.CancellationToken());

            // Check if non empty search result is returned.
            Assert.True(uiSearchResults.Count() > 0);
            //check if there is atleast one result which has Id exactly as the search terms.
            Assert.True(uiSearchResults.Any(p => p.Identity.Id.Equals(SearchTerm, StringComparison.OrdinalIgnoreCase)));

            PSSearchResource psResource = await repo.GetResource <PSSearchResource>();

            IEnumerable <PSSearchMetadata> psSearchResults = await psResource.Search(SearchTerm, filter, 0, 100, new System.Threading.CancellationToken());

            SimpleSearchResource simpleSearch = await repo.GetResource <SimpleSearchResource>();

            IEnumerable <SimpleSearchMetadata> simpleSearchResults = await simpleSearch.Search(SearchTerm, filter, 0, 100, new System.Threading.CancellationToken());

            //Check that exact search results are returned irrespective of search resource ( UI, powershell and commandline).
            Assert.True(uiSearchResults.Count() == psSearchResults.Count());
            Assert.True(psSearchResults.Count() == simpleSearchResults.Count());
        }
示例#2
0
        public async Task TestAllSearchResources(string SourceUrl)
        {
            SourceRepository     repo           = GetSourceRepository(SourceUrl);
            UISearchResource     resource       = repo.GetResource <UISearchResource>();
            SearchLatestResource latestResource = repo.GetResource <SearchLatestResource>();

            //Check if we are able to obtain a resource
            Assert.True(resource != null);
            //check if the resource is of type IVsSearch.
            SearchFilter         filter  = new SearchFilter(); //create a dummy filter.
            List <FrameworkName> fxNames = new List <FrameworkName>();

            fxNames.Add(new FrameworkName(".NETFramework, Version=4.5"));
            filter.SupportedFrameworks = fxNames.Select(e => e.ToString());
            string SearchTerm = "dotnetrdf";

            IEnumerable <UISearchMetadata> uiSearchResults = await resource.Search(SearchTerm, filter, 0, 100, new CancellationToken());

            var latestSearchResults = await latestResource.Search(SearchTerm, filter, 0, 100, CancellationToken.None);

            // Check if non empty search result is returned.
            Assert.True(uiSearchResults.Count() > 0);

            //check if there is atleast one result which has Id exactly as the search terms.
            Assert.True(uiSearchResults.Any(p => p.Identity.Id.Equals(SearchTerm, StringComparison.OrdinalIgnoreCase)));

            foreach (var result in uiSearchResults)
            {
                Assert.Equal(result.Identity.Id, result.LatestPackageMetadata.Identity.Id);
                Assert.Equal(result.Identity.Version.ToNormalizedString(), result.LatestPackageMetadata.Identity.Version.ToNormalizedString());
            }

            // Verify search and latest search return the same results
            var searchEnumerator = uiSearchResults.GetEnumerator();
            var latestEnumerator = latestSearchResults.GetEnumerator();

            for (int i = 0; i < 10; i++)
            {
                searchEnumerator.MoveNext();
                latestEnumerator.MoveNext();

                Assert.Equal(searchEnumerator.Current.LatestPackageMetadata.Identity.Id, latestEnumerator.Current.Id);
                Assert.Equal(searchEnumerator.Current.LatestPackageMetadata.LicenseUrl, latestEnumerator.Current.LicenseUrl);
                //Assert.Equal(searchEnumerator.Current.LatestPackageMetadata.ReportAbuseUrl, latestEnumerator.Current.ReportAbuseUrl);
                Assert.Equal(searchEnumerator.Current.LatestPackageMetadata.RequireLicenseAcceptance, latestEnumerator.Current.RequireLicenseAcceptance);
                Assert.Equal(searchEnumerator.Current.LatestPackageMetadata.Summary, latestEnumerator.Current.Summary);
                Assert.Equal(searchEnumerator.Current.LatestPackageMetadata.Authors, String.Join(" ", latestEnumerator.Current.Authors));
                Assert.Equal(searchEnumerator.Current.LatestPackageMetadata.Title, latestEnumerator.Current.Title);
            }

            PSSearchResource psResource = repo.GetResource <PSSearchResource>();
            IEnumerable <PSSearchMetadata> psSearchResults = await psResource.Search(SearchTerm, filter, 0, 100, new System.Threading.CancellationToken());

            SimpleSearchResource simpleSearch = repo.GetResource <SimpleSearchResource>();
            IEnumerable <SimpleSearchMetadata> simpleSearchResults = await simpleSearch.Search(SearchTerm, filter, 0, 100, new System.Threading.CancellationToken());

            //Check that exact search results are returned irrespective of search resource ( UI, powershell and commandline).
            Assert.Equal(uiSearchResults.Count(), psSearchResults.Count());
            Assert.Equal(psSearchResults.Count(), simpleSearchResults.Count());
        }
示例#3
0
        public async Task TestAllSearchTitle(string SourceUrl)
        {
            SourceRepository repo     = GetSourceRepository(SourceUrl);
            UISearchResource resource = repo.GetResource <UISearchResource>();

            SearchFilter filter     = new SearchFilter();
            string       searchTerm = "Json";

            IEnumerable <UISearchMetadata> uiSearchResults = await resource.Search(searchTerm, filter, 0, 100, new CancellationToken());

            UISearchMetadata metadata = uiSearchResults.Where(e => StringComparer.OrdinalIgnoreCase.Equals("newtonsoft.json", e.Identity.Id)).Single();

            // TODO: check the title value once the server is updated
            Assert.True(!String.IsNullOrEmpty(metadata.Title));
            Assert.True(!String.IsNullOrEmpty(metadata.LatestPackageMetadata.Title));
        }
示例#4
0
        public async override Task <IEnumerable <PSSearchMetadata> > Search(string search, SearchFilter filters, int skip, int take, System.Threading.CancellationToken token)
        {
            IEnumerable <UISearchMetadata> searchResults = await uiSearchResource.Search(search, filters, skip, take, token);

            return(searchResults.Select(item => GetPSSearch(item)));
        }