public async Task <V2SearchResponse> V2SearchAsync( int?skip = DefaultSkip, int?take = DefaultTake, bool?ignoreFilter = false, bool?countOnly = false, bool?prerelease = false, string semVerLevel = null, string q = null, string sortBy = null, bool?luceneQuery = true, string packageType = null, bool?testData = false, bool?debug = false) { await EnsureInitializedAsync(); var request = new V2SearchRequest { Skip = skip ?? DefaultSkip, Take = take ?? DefaultTake, IgnoreFilter = ignoreFilter ?? false, CountOnly = countOnly ?? false, IncludePrerelease = prerelease ?? false, IncludeSemVer2 = ParameterUtilities.ParseIncludeSemVer2(semVerLevel), Query = q, SortBy = ParameterUtilities.ParseV2SortBy(sortBy), LuceneQuery = luceneQuery ?? true, PackageType = packageType, IncludeTestData = testData ?? false, ShowDebug = debug ?? false, }; return(await _searchService.V2SearchAsync(request)); }
public async Task SupportsNullParameters() { V2SearchRequest lastRequest = null; _searchService .Setup(x => x.V2SearchAsync(It.IsAny <V2SearchRequest>())) .ReturnsAsync(() => _v2SearchResponse) .Callback <V2SearchRequest>(x => lastRequest = x); await _target.V2SearchAsync( skip : null, take : null, ignoreFilter : null, countOnly : null, prerelease : null, semVerLevel : null, q : null, sortBy : null, luceneQuery : null, debug : null); _searchService.Verify(x => x.V2SearchAsync(It.IsAny <V2SearchRequest>()), Times.Once); Assert.NotNull(lastRequest); Assert.Equal(0, lastRequest.Skip); Assert.Equal(20, lastRequest.Take); Assert.False(lastRequest.IgnoreFilter); Assert.False(lastRequest.CountOnly); Assert.False(lastRequest.IncludePrerelease); Assert.False(lastRequest.IncludeSemVer2); Assert.Null(lastRequest.Query); Assert.True(lastRequest.LuceneQuery); Assert.False(lastRequest.ShowDebug); }
public async Task UsesProvidedParameters() { V2SearchRequest lastRequest = null; _searchService .Setup(x => x.V2SearchAsync(It.IsAny <V2SearchRequest>())) .ReturnsAsync(() => _v2SearchResponse) .Callback <V2SearchRequest>(x => lastRequest = x); await _target.V2SearchAsync( skip : -20, take : 30000, ignoreFilter : true, countOnly : true, prerelease : true, semVerLevel : "2.0.0", q : "windows azure storage", sortBy : "lastEdited", luceneQuery : true, debug : true); _searchService.Verify(x => x.V2SearchAsync(It.IsAny <V2SearchRequest>()), Times.Once); Assert.NotNull(lastRequest); Assert.Equal(-20, lastRequest.Skip); Assert.Equal(30000, lastRequest.Take); Assert.True(lastRequest.IgnoreFilter); Assert.True(lastRequest.CountOnly); Assert.True(lastRequest.IncludePrerelease); Assert.True(lastRequest.IncludeSemVer2); Assert.Equal("windows azure storage", lastRequest.Query); Assert.True(lastRequest.LuceneQuery); Assert.True(lastRequest.ShowDebug); }
public async Task HasDefaultParameters() { V2SearchRequest lastRequest = null; _searchService .Setup(x => x.V2SearchAsync(It.IsAny <V2SearchRequest>())) .ReturnsAsync(() => _v2SearchResponse) .Callback <V2SearchRequest>(x => lastRequest = x); await _target.V2SearchAsync(); _searchService.Verify(x => x.V2SearchAsync(It.IsAny <V2SearchRequest>()), Times.Once); Assert.NotNull(lastRequest); Assert.Equal(0, lastRequest.Skip); Assert.Equal(20, lastRequest.Take); Assert.False(lastRequest.IgnoreFilter); Assert.False(lastRequest.CountOnly); Assert.False(lastRequest.IncludePrerelease); Assert.False(lastRequest.IncludeSemVer2); Assert.False(lastRequest.IncludeTestData); Assert.Null(lastRequest.Query); Assert.True(lastRequest.LuceneQuery); Assert.False(lastRequest.ShowDebug); Assert.Null(lastRequest.PackageType); }