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