public async Task HijackIndexAndGetOperation(bool includePrerelease, bool includeSemVer2, bool returned) { _v2Request.IgnoreFilter = true; _v2Request.IncludePrerelease = includePrerelease; _v2Request.IncludeSemVer2 = includeSemVer2; _hijackDocument.Prerelease = true; _hijackDocument.SemVerLevel = SemVerLevelKey.SemVer2; _operation = IndexOperation.Get(_key); var expectedDocument = returned ? _hijackDocument : null; var response = await _target.V2SearchAsync(_v2Request); Assert.Same(_v2Response, response); _operationBuilder.Verify( x => x.V2SearchWithHijackIndex(_v2Request), Times.Once); _hijackOperations.Verify( x => x.GetOrNullAsync <HijackDocument.Full>(_key), Times.Once); _responseBuilder.Verify( x => x.V2FromHijackDocument(_v2Request, _key, expectedDocument, It.Is <TimeSpan>(t => t > TimeSpan.Zero)), Times.Once); _telemetryService.Verify( x => x.TrackV2GetDocumentWithHijackIndex(It.Is <TimeSpan>(t => t > TimeSpan.Zero)), Times.Once); }
public async Task SearchIndexAndGetOperation() { _operation = IndexOperation.Get(_key); var ex = await Assert.ThrowsAsync <NotImplementedException>(() => _target.AutocompleteAsync(_autocompleteRequest)); Assert.Equal("The operation type Get is not supported.", ex.Message); _operationBuilder.Verify( x => x.Autocomplete(_autocompleteRequest), Times.Once); _searchOperations.Verify( x => x.GetOrNullAsync <SearchDocument.Full>(It.IsAny <string>()), Times.Never); _telemetryService.Verify( x => x.TrackV3GetDocument(It.IsAny <TimeSpan>()), Times.Never); }
private bool TryGetHijackDocumentByKey( SearchRequest request, ParsedQuery parsed, out IndexOperation indexOperation) { if (PagedToFirstItem(request) && parsed.Grouping.Count == 2 && TryGetSinglePackageId(parsed, out var packageId) && TryGetSingleVersion(parsed, out var normalizedVersion)) { var documentKey = DocumentUtilities.GetHijackDocumentKey(packageId, normalizedVersion); indexOperation = IndexOperation.Get(documentKey); return(true); } indexOperation = null; return(false); }
private bool TryGetSearchDocumentByKey( SearchRequest request, ParsedQuery parsed, out IndexOperation indexOperation) { if (PagedToFirstItem(request) && parsed.Grouping.Count == 1 && TryGetSinglePackageId(parsed, out var packageId)) { var searchFilters = _parametersBuilder.GetSearchFilters(request); var documentKey = DocumentUtilities.GetSearchDocumentKey(packageId, searchFilters); indexOperation = IndexOperation.Get(documentKey); return(true); } indexOperation = null; return(false); }
public async Task SearchIndexAndGetOperation() { _operation = IndexOperation.Get(_key); var response = await _target.V3SearchAsync(_v3Request); Assert.Same(_v3Response, response); _operationBuilder.Verify( x => x.V3Search(_v3Request), Times.Once); _searchOperations.Verify( x => x.GetOrNullAsync <SearchDocument.Full>(_key), Times.Once); _responseBuilder.Verify( x => x.V3FromSearchDocument(_v3Request, _key, _searchDocument, It.Is <TimeSpan>(t => t > TimeSpan.Zero)), Times.Once); _telemetryService.Verify( x => x.TrackV3GetDocument(It.Is <TimeSpan>(t => t > TimeSpan.Zero)), Times.Once); }