public NpmRepositoryTest()
        {
            RepoUrl = Environment.GetEnvironmentVariable(EnvVar_Url);
            ApiKey  = Environment.GetEnvironmentVariable(EnvVar_ApiKey);
            Assert.True(!string.IsNullOrEmpty(RepoUrl), $"No environment variable found for {EnvVar_Url}");
            Assert.True(!string.IsNullOrEmpty(ApiKey), $"No environment variable found for {EnvVar_ApiKey}");

            ServiceProvider = new ServiceCollection()
                              .AddLogging(loggingBuilder => { loggingBuilder.AddDebug(); })
                              .BuildServiceProvider();

            LoggerFactory = ServiceProvider.GetRequiredService <ILoggerFactory>();

            var sourceRepoFeedConfig = new Settings.Feed
            {
                Name = "packagerepo.npm.test-source",
            };

            sourceRepoFeedConfig.Settings.Add("Uri", (RepoUrl.EndsWith("/") ? RepoUrl.Substring(0, RepoUrl.Length - 1) : RepoUrl) + "-source/");
            sourceRepoFeedConfig.Settings.Add("ApiKey", ApiKey);

            var targetRepoFeedConfig = new Settings.Feed
            {
                Name = "packagerepo.npm.test",
            };

            targetRepoFeedConfig.Settings.Add("Uri", RepoUrl);
            targetRepoFeedConfig.Settings.Add("ApiKey", ApiKey);

            SourceRepo = new NpmRepository(sourceRepoFeedConfig, LoggerFactory);
            TargetRepo = new NpmRepository(targetRepoFeedConfig, LoggerFactory);
        }
        public async Task Test_NpmRepository_Feed_Access_Forbidden()
        {
            var repoFeedConfig = new Settings.Feed
            {
                Name = "npm.test",
            };

            repoFeedConfig.Settings.Add("Uri", RepoUrl);
            var sourceRepo = new NpmRepository(repoFeedConfig, LoggerFactory);

            await Assert.ThrowsAsync <WebException>(async() => await sourceRepo.ListAsync(null, false, false).ToListAsync());
        }
        public async Task Test_NpmRepository_Uri_Doesnt_Exist()
        {
            var repoFeedConfig = new Settings.Feed
            {
                Name = "npm.notfound"
            };

            repoFeedConfig.Settings.Add("Uri", "http://www.somedummywebsiteurl.com/");

            var sourceRepo = new NpmRepository(repoFeedConfig, LoggerFactory);

            await Assert.ThrowsAsync <WebException>(async() => await sourceRepo.ListAsync(null, false, false).ToListAsync());
        }
        public async Task Test_NpmRepository_Feed_Doesnt_Exist()
        {
            var repoFeedConfig = new Settings.Feed
            {
                Name = "npm.notfound"
            };

            repoFeedConfig.Settings.Add("Uri", RepoUrl + "npm.notfound");
            repoFeedConfig.Settings.Add("ApiKey", ApiKey);

            var sourceRepo = new NpmRepository(repoFeedConfig, LoggerFactory);

            await Assert.ThrowsAsync <WebException>(async() => await sourceRepo.ListAsync(null, false, false).ToListAsync());
        }