public void Should_Set_Source_Specified_In_Directive_As_Primary_But_Not_For_Settings() { var nugetV3Api = "https://api.nuget.org/v3/index.json"; var nugetV2Api = "https://packages.nuget.org/api/v2"; var primaryApi = "https://foo.bar/api.json"; var package = new PackageReference($"nuget:{primaryApi}?package=First.Package"); var settings = new FakeNuGetSettings(); settings.AddOrUpdate(ConfigurationConstants.PackageSources, new SourceItem("V3", nugetV3Api)); settings.AddOrUpdate(ConfigurationConstants.PackageSources, new SourceItem("V2", nugetV2Api)); var configuration = new CakeConfiguration(new Dictionary <string, string>() { [Constants.NuGet.Source] = string.Empty, }); var provider = new NuGetSourceRepositoryProvider(settings, configuration, package, "/Work/packages/"); Assert.Single(provider.PrimaryRepositories); Assert.Contains(provider.PrimaryRepositories, p => p.PackageSource.Source == primaryApi); Assert.Equal(3, provider.Repositories.Count()); Assert.Contains(provider.Repositories, p => p.PackageSource.Source == primaryApi); Assert.Contains(provider.Repositories, p => p.PackageSource.Source == nugetV2Api); Assert.Contains(provider.Repositories, p => p.PackageSource.Source == nugetV3Api); }
public void Should_Use_Feed_Specified_In_NuGet_Config_If_Available() { var feed = "https://foo.bar/api.json"; var package = new PackageReference($"nuget:{feed}?package=First.Package"); var settings = new FakeNuGetSettings(); settings.AddOrUpdate(ConfigurationConstants.PackageSources, new SourceItem("foobar", feed)); settings.AddOrUpdate(ConfigurationConstants.CredentialsSectionName, new CredentialsItem("foobar", "*****@*****.**", "p455w0rdz", true, "foo")); var configuration = new CakeConfiguration(new Dictionary <string, string>() { [Constants.NuGet.Source] = string.Empty, }); var provider = new NuGetSourceRepositoryProvider(settings, configuration, package, "/Work/packages/"); Assert.Single(provider.Repositories); Assert.Contains(provider.Repositories, p => p.PackageSource.Source == feed && p.PackageSource.Credentials.Username == "*****@*****.**" && p.PackageSource.Credentials.Password == "p455w0rdz"); }
public void Should_Set_Source_From_Settings_If_Cake_Config_Source_Is_Not_Provided() { var settingsApi = "https://foo.bar/api.json"; var package = new PackageReference($"nuget:?package=First.Package"); var settings = new FakeNuGetSettings(); settings.AddOrUpdate(ConfigurationConstants.PackageSources, new SourceItem("foobar", settingsApi)); var configuration = new CakeConfiguration(new Dictionary <string, string>() { [Constants.NuGet.Source] = string.Empty, }); var provider = new NuGetSourceRepositoryProvider(settings, configuration, package, "/Work/packages/"); Assert.Single(provider.Repositories); Assert.Contains(provider.Repositories, p => p.PackageSource.Source == settingsApi); }
public void Should_Not_Set_Source_From_Settings_If_Cake_Config_Source_Is_Provided() { var nugetV3Api = "https://api.nuget.org/v3/index.json"; var nugetV2Api = "https://packages.nuget.org/api/v2"; var settingsApi = "https://foo.bar/api.json"; var package = new PackageReference($"nuget:?package=First.Package"); var settings = new FakeNuGetSettings(); settings.AddOrUpdate(ConfigurationConstants.PackageSources, new SourceItem("foobar", settingsApi)); var configuration = new CakeConfiguration(new Dictionary <string, string>() { [Constants.NuGet.Source] = $"{nugetV3Api};{nugetV2Api}", }); var provider = new NuGetSourceRepositoryProvider(settings, configuration, package, "/Work/packages/"); Assert.Equal(2, provider.Repositories.Count()); Assert.Contains(provider.Repositories, p => p.PackageSource.Source == nugetV2Api); Assert.Contains(provider.Repositories, p => p.PackageSource.Source == nugetV3Api); }