public void PushCommandUsesNuGetOrgWhenNoSourceSpecified(string input, string expected) { var push = new PushCommand(); push.SourceProvider = CreateSourceProvider(); push.Settings = CreateSettings(); Assert.Equal(expected, push.ResolveSource(input)); }
public void PushCommandUsesConfFileWhenDefaultPushSourceSpecified() { const string src = "http://foo/bar/baz"; var push = new PushCommand(); push.SourceProvider = CreateSourceProvider(); push.Settings = CreateSettings(src); Assert.Equal(src, push.ResolveSource(@"X:\test\foobar.symbols.nupkg")); }
public void PushCommandUsesSourceWhenSpecifiedEvenWhenSpecifiedAlsoInConfFile() { const string srcCmdLine = "http://foo/bar/baz1"; const string srcConfFile = "http://foo/bar/baz2"; var push = new PushCommand(); push.SourceProvider = CreateSourceProvider(); push.Settings = CreateSettings(srcConfFile); push.Source = srcCmdLine; Assert.Equal(srcCmdLine, push.ResolveSource(@"X:\test\foobar.symbols.nupkg")); }
public void PublishNewPackageVersion(string packagePath) { //string nugetSource = "nuget.org"; //packageServer.PushPackage("key", null, -1, 60 * 1000, false); PushCommand cmd = new PushCommand(); cmd.Arguments.Add(packagePath); cmd.Source = "nuget.org"; cmd.ApiKey = "4f3ad946-b109-44a7-849e-cc19d799f719"; cmd.Timeout = 10 * 1000; cmd.Execute(); throw new NotImplementedException(); }
public static Response Push(NuGetPushRequest request) { var console = new Console(); var command = new PushCommand { Source = request.NugetHost, ApiKey = request.ApiKey, Console = console, Verbosity = Verbosity.Detailed, }; command.Arguments.Add(request.Package); try { command.Execute(); } catch (Exception e) { console.WriteError(e); } return new Response(console.Messages); }
public void PushCommandUsesSourceFromConfigurationDefaultsWhenDefaultPushSourceNotSpecifiedByUserOrInConfigFile() { // Arrange var push = new PushCommand(); push.SourceProvider = CreateSourceProvider(); push.Settings = CreateSettings(); // Set Configuration Defaults var mockFileSystem = new MockFileSystem(); var configurationDefaultsPath = "NuGetDefaults.config"; mockFileSystem.AddFile(configurationDefaultsPath, @" <configuration> <config> <add key='DefaultPushSource' value='http://contoso.com/packages/' /> </config> </configuration>"); ConfigurationDefaults configurationDefaults = new ConfigurationDefaults(mockFileSystem, configurationDefaultsPath); // Act & Assert Assert.Equal(push.ResolveSource(@"X:\test\foobar.symbols.nupkg", configurationDefaults.DefaultPushSource), "http://contoso.com/packages/"); }
public void PushCommandThrowsAnExceptionWhenPackageFileDoesntExist() { // Arrange var packageFilename = "non.existant.file.nupkg"; var push = new PushCommand(); push.Arguments.Add(packageFilename); push.ApiKey = "apikey"; var expectedErrorMessage = String.Format("File does not exist ({0}).", packageFilename); // Act & Assert ExceptionAssert.Throws<CommandLineException>(() => push.Execute(), expectedErrorMessage); }