Exemplo n.º 1
0
        public async Task MapsAllSortOrders(SortOrder sortOrder)
        {
            // Arrange
            var gallerySearchClient = new GallerySearchClient(ResilientClientForTest.GetTestInstance(HttpStatusCode.OK));

            // Act
            var response = await gallerySearchClient.Search(query : string.Empty, sortBy : sortOrder);

            // Assert
            var httpResponseContentAsString = await response.HttpResponse.Content.ReadAsStringAsync();

            var queryString       = JObject.Parse(httpResponseContentAsString)["queryString"].Value <string>();
            var parsedQueryString = HttpUtility.ParseQueryString(queryString);

            Assert.Contains(sortOrder, SortNames.Keys);
            Assert.Equal(SortNames[sortOrder], parsedQueryString["sortBy"]);
        }
Exemplo n.º 2
0
        public async Task SearchArgumentsAreCorrectSet(string query,
                                                       string projectTypeFilter,
                                                       bool includePrerelease,
                                                       string packageType,
                                                       SortOrder sortBy,
                                                       int skip,
                                                       int take,
                                                       bool isLuceneQuery,
                                                       bool countOnly,
                                                       bool explain,
                                                       bool getAllVersions,
                                                       string supportedFramework,
                                                       string semVerLevel,
                                                       string expectedResult)
        {
            // Arrange
            var gallerySearchClient = new GallerySearchClient(ResilientClientForTest.GetTestInstance(HttpStatusCode.OK));

            // Act
            var response = await gallerySearchClient.Search(query,
                                                            projectTypeFilter,
                                                            includePrerelease,
                                                            packageType,
                                                            sortBy,
                                                            skip,
                                                            take,
                                                            isLuceneQuery,
                                                            countOnly,
                                                            explain,
                                                            getAllVersions,
                                                            supportedFramework,
                                                            semVerLevel);

            var httpResponseContentAsString = await response.HttpResponse.Content.ReadAsStringAsync();

            var path        = JObject.Parse(httpResponseContentAsString)["path"].Value <string>();
            var queryString = JObject.Parse(httpResponseContentAsString)["queryString"].Value <string>();
            var statusCode  = response.StatusCode;

            // Assert
            Assert.Equal(200, (int)statusCode);
            Assert.True(response.IsSuccessStatusCode);
            Assert.Equal("search/query", path);
            Assert.Equal(expectedResult, queryString);
        }
        public async Task GetDiagnosticsUsesTheCorrectPath()
        {
            // Arrange
            var gallerySearchClient = new GallerySearchClient(ResilientClientForTest.GetTestInstance(HttpStatusCode.OK));

            // Act
            var response = await gallerySearchClient.GetDiagnostics();

            var httpResponseContentAsString = await response.HttpResponse.Content.ReadAsStringAsync();

            var path        = JObject.Parse(httpResponseContentAsString)["path"].Value <string>();
            var queryString = JObject.Parse(httpResponseContentAsString)["queryString"].Value <string>();
            var statusCode  = response.StatusCode;

            // Assert
            Assert.Equal(200, (int)statusCode);
            Assert.True(response.IsSuccessStatusCode);
            Assert.Equal("search/diag", path);
            Assert.Null(queryString);
        }