Ejemplo n.º 1
0
        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());
        }
Ejemplo n.º 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());
        }
Ejemplo n.º 3
0
        public async Task SimpleSearchTest()
        {
            SourceRepository     repo     = GetSourceRepository(RCRootUrl);
            SimpleSearchResource resource = await repo.GetResource <SimpleSearchResource>();

            Assert.True(resource != null);
            var results = await resource.Search("elmah", new SearchFilter(), 0, 10, CancellationToken.None);

            //*TODOs: Use a proper test package whose latest version is fixed instead of using nuget.core.
            Assert.True(results.Count() == 10);
        }