public BaseFacts(ITestOutputHelper output) { _collector = new Mock<ICollector>(); _storageFactory = new Mock<IStorageFactory>(); _httpMessageHandler = new Mock<TestHttpMessageHandler>() { CallBase = true }; _blobContainerBuilder = new Mock<IBlobContainerBuilder>(); _indexBuilder = new Mock<IIndexBuilder>(); _options = new Mock<IOptionsSnapshot<Catalog2AzureSearchConfiguration>>(); _logger = output.GetLogger<Catalog2AzureSearchCommand>(); _config = new Catalog2AzureSearchConfiguration { StorageConnectionString = "UseDevelopmentStorage=true", StorageContainer = "container-name", }; _storage = new TestCursorStorage(new Uri("https://example/base/")); _options.Setup(x => x.Value).Returns(() => _config); _storageFactory.Setup(x => x.Create(It.IsAny<string>())).Returns(() => _storage); _target = new Catalog2AzureSearchCommand( _collector.Object, _storageFactory.Object, () => _httpMessageHandler.Object, _blobContainerBuilder.Object, _indexBuilder.Object, _options.Object, _logger); }
public Db2AzureSearchCommandFacts(ITestOutputHelper output) { _producer = new Mock <INewPackageRegistrationProducer>(); _builder = new Mock <IPackageEntityIndexActionBuilder>(); _blobContainerBuilder = new Mock <IBlobContainerBuilder>(); _indexBuilder = new Mock <IIndexBuilder>(); _batchPusher = new Mock <IBatchPusher>(); _catalogClient = new Mock <ICatalogClient>(); _storageFactory = new Mock <IStorageFactory>(); _ownerDataClient = new Mock <IOwnerDataClient>(); _downloadDataClient = new Mock <IDownloadDataClient>(); _verifiedPackagesDataClient = new Mock <IVerifiedPackagesDataClient>(); _popularityTransferDataClient = new Mock <IPopularityTransferDataClient>(); _options = new Mock <IOptionsSnapshot <Db2AzureSearchConfiguration> >(); _developmentOptions = new Mock <IOptionsSnapshot <Db2AzureSearchDevelopmentConfiguration> >(); _logger = output.GetLogger <Db2AzureSearchCommand>(); _config = new Db2AzureSearchConfiguration { MaxConcurrentBatches = 1, StorageContainer = "container-name", }; _developmentConfig = new Db2AzureSearchDevelopmentConfiguration(); _storage = new TestCursorStorage(new Uri("https://example/base/")); _initialAuxiliaryData = new InitialAuxiliaryData( owners: new SortedDictionary <string, SortedSet <string> >(), downloads: new DownloadData(), excludedPackages: new HashSet <string>(), verifiedPackages: new HashSet <string>(), popularityTransfers: new PopularityTransferData()); _options .Setup(x => x.Value) .Returns(() => _config); _developmentOptions .Setup(x => x.Value) .Returns(() => _developmentConfig); _producer .Setup(x => x.ProduceWorkAsync(It.IsAny <ConcurrentBag <NewPackageRegistration> >(), It.IsAny <CancellationToken>())) .ReturnsAsync(() => _initialAuxiliaryData); _builder .Setup(x => x.AddNewPackageRegistration(It.IsAny <NewPackageRegistration>())) .Returns(() => new IndexActions( new IndexAction <KeyedDocument> [0], new IndexAction <KeyedDocument> [0], new ResultAndAccessCondition <VersionListData>( new VersionListData(new Dictionary <string, VersionPropertiesData>()), AccessConditionWrapper.GenerateEmptyCondition()))); _batchPusher.SetReturnsDefault(Task.FromResult(new BatchPusherResult())); _catalogClient .Setup(x => x.GetIndexAsync(It.IsAny <string>())) .ReturnsAsync(new CatalogIndex()); _storageFactory .Setup(x => x.Create(It.IsAny <string>())) .Returns(() => _storage); _blobContainerBuilder .Setup(x => x.DeleteIfExistsAsync()) .ReturnsAsync(true); _target = new Db2AzureSearchCommand( _producer.Object, _builder.Object, _blobContainerBuilder.Object, _indexBuilder.Object, () => _batchPusher.Object, _catalogClient.Object, _storageFactory.Object, _ownerDataClient.Object, _downloadDataClient.Object, _verifiedPackagesDataClient.Object, _popularityTransferDataClient.Object, _options.Object, _developmentOptions.Object, _logger); }