Exemplo n.º 1
0
            public async Task UpdatesSearchDocumentsWithVersionMatchingAllFilters()
            {
                VersionListDataResult = new ResultAndAccessCondition <VersionListData>(
                    new VersionListData(new Dictionary <string, VersionPropertiesData>
                {
                    {
                        "1.0.0",
                        new VersionPropertiesData(listed: true, semVer2: false)
                    },
                }),
                    AccessConditionWrapper.GenerateIfNotExistsCondition());

                var indexActions = await Target.UpdateAsync(Data.PackageId, BuildDocument);

                Assert.Same(VersionListDataResult, indexActions.VersionListDataResult);
                Assert.Empty(indexActions.Hijack);

                Assert.Equal(4, indexActions.Search.Count);
                Assert.All(indexActions.Search, x => Assert.IsType <SearchDocument.UpdateOwners>(x.Document));
                Assert.All(indexActions.Search, x => Assert.Equal(IndexActionType.Merge, x.ActionType));

                Assert.Single(indexActions.Search, x => x.Document.Key == SearchFilters.Default.ToString());
                Assert.Single(indexActions.Search, x => x.Document.Key == SearchFilters.IncludePrerelease.ToString());
                Assert.Single(indexActions.Search, x => x.Document.Key == SearchFilters.IncludeSemVer2.ToString());
                Assert.Single(indexActions.Search, x => x.Document.Key == SearchFilters.IncludePrereleaseAndSemVer2.ToString());
            }
Exemplo n.º 2
0
 public IndexActions(
     IReadOnlyList <IndexAction <KeyedDocument> > search,
     IReadOnlyList <IndexAction <KeyedDocument> > hijack,
     ResultAndAccessCondition <VersionListData> versionListDataResult)
 {
     Search = search ?? throw new ArgumentNullException(nameof(search));
     Hijack = hijack ?? throw new ArgumentNullException(nameof(hijack));
     VersionListDataResult = versionListDataResult ?? throw new ArgumentNullException(nameof(versionListDataResult));
 }
Exemplo n.º 3
0
            public async Task UpdatesSearchDocumentsWithNoVersions()
            {
                VersionListDataResult = new ResultAndAccessCondition <VersionListData>(
                    new VersionListData(new Dictionary <string, VersionPropertiesData>()),
                    AccessConditionWrapper.GenerateIfNotExistsCondition());

                var indexActions = await Target.UpdateAsync(Data.PackageId, BuildDocument);

                Assert.Same(VersionListDataResult, indexActions.VersionListDataResult);
                Assert.Empty(indexActions.Hijack);
                Assert.Empty(indexActions.Search);
            }
Exemplo n.º 4
0
            public Facts(ITestOutputHelper output)
            {
                VersionListDataClient = new Mock <IVersionListDataClient>();
                Search = new Mock <ISearchDocumentBuilder>();
                Logger = output.GetLogger <SearchIndexActionBuilder>();

                VersionListDataResult = new ResultAndAccessCondition <VersionListData>(
                    new VersionListData(new Dictionary <string, VersionPropertiesData>()),
                    AccessConditionWrapper.GenerateIfNotExistsCondition());

                VersionListDataClient
                .Setup(x => x.ReadAsync(It.IsAny <string>()))
                .ReturnsAsync(() => VersionListDataResult);
                Search
                .Setup(x => x.UpdateOwners(It.IsAny <string>(), It.IsAny <SearchFilters>(), It.IsAny <string[]>()))
                .Returns <string, SearchFilters, string[]>((_, sf, __) => new SearchDocument.UpdateOwners
                {
                    Key = sf.ToString(),
                });

                Target = new SearchIndexActionBuilder(VersionListDataClient.Object, Logger);
            }