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);
            }
Пример #2
0
            public BaseFacts(ITestOutputHelper output)
            {
                _registrationClient = new Mock <IRegistrationClient>();
                _catalogClient      = new Mock <ICatalogClient>();
                _options            = new Mock <IOptionsSnapshot <Catalog2AzureSearchConfiguration> >();
                _config             = new Catalog2AzureSearchConfiguration
                {
                    MaxConcurrentBatches = 1,
                };
                _telemetryService = new Mock <IAzureSearchTelemetryService>();
                _logger           = output.GetLogger <CatalogLeafFetcher>();

                _options.Setup(x => x.Value).Returns(() => _config);

                _config.RegistrationsBaseUrl = "https://example/v3-registration/";
                _versions = new List <IReadOnlyList <NuGetVersion> >
                {
                    new List <NuGetVersion>
                    {
                        Parse("1.0.0"),
                    },
                    new List <NuGetVersion>
                    {
                        Parse("1.0.0"),
                        Parse("2.0.0-alpha"),
                    },
                    new List <NuGetVersion>
                    {
                        Parse("1.0.0"),
                        Parse("3.0.0+git"),
                    },
                    new List <NuGetVersion>
                    {
                        Parse("1.0.0"),
                        Parse("2.0.0-alpha"),
                        Parse("3.0.0+git"),
                        Parse("4.0.0-beta.1"),
                    },
                };
                _eachVersion = new[]
                {
                    Parse("1.0.0"),
                    Parse("2.0.0-alpha"),
                    Parse("3.0.0+git"),
                    Parse("4.0.0-beta.1"),
                };

                _target = new CatalogLeafFetcher(
                    _registrationClient.Object,
                    _catalogClient.Object,
                    _options.Object,
                    _telemetryService.Object,
                    _logger);
            }
            public BaseFacts(ITestOutputHelper output)
            {
                _catalogClient             = new Mock <ICatalogClient>();
                _catalogIndexActionBuilder = new Mock <ICatalogIndexActionBuilder>();
                _batchPusher        = new Mock <IBatchPusher>();
                _fixUpEvaluator     = new Mock <IDocumentFixUpEvaluator>();
                _utilityOptions     = new Mock <IOptionsSnapshot <CommitCollectorConfiguration> >();
                _collectorOptions   = new Mock <IOptionsSnapshot <Catalog2AzureSearchConfiguration> >();
                _utilityConfig      = new CommitCollectorConfiguration();
                _collectorConfig    = new Catalog2AzureSearchConfiguration();
                _telemetryService   = new Mock <IAzureSearchTelemetryService>();
                _v3TelemetryService = new Mock <IV3TelemetryService>();
                _logger             = output.GetLogger <AzureSearchCollectorLogic>();
                _utilityLogger      = output.GetLogger <CommitCollectorUtility>();

                _batchPusher.SetReturnsDefault(Task.FromResult(new BatchPusherResult()));
                _utilityOptions.Setup(x => x.Value).Returns(() => _utilityConfig);
                _utilityConfig.MaxConcurrentCatalogLeafDownloads = 1;
                _collectorOptions.Setup(x => x.Value).Returns(() => _collectorConfig);
                _collectorConfig.MaxConcurrentBatches = 1;
                _fixUpEvaluator
                .Setup(x => x.TryFixUpAsync(
                           It.IsAny <IReadOnlyList <CatalogCommitItem> >(),
                           It.IsAny <ConcurrentBag <IdAndValue <IndexActions> > >(),
                           It.IsAny <InvalidOperationException>()))
                .ReturnsAsync(() => DocumentFixUp.IsNotApplicable());

                _utility = new CommitCollectorUtility(
                    _catalogClient.Object,
                    _v3TelemetryService.Object,
                    _utilityOptions.Object,
                    _utilityLogger);

                _target = new AzureSearchCollectorLogic(
                    _catalogIndexActionBuilder.Object,
                    () => _batchPusher.Object,
                    _fixUpEvaluator.Object,
                    _utility,
                    _collectorOptions.Object,
                    _telemetryService.Object,
                    _logger);
            }