public void TestVerbosityQuiet_DoesNotShowInfoMessages() { using (var preserver = new NuGet.CommandLine.Test.DefaultConfigurationFilePreserver()) { // Arrange var args = new string[] { "nuget", "add", "source", "http://test_source", "--name", "test_source", "--verbosity", "Quiet" }; var root = Directory.GetDirectoryRoot(Directory.GetCurrentDirectory()); // Act // Set the working directory to C:\, otherwise, // the test will change the nuget.config at the code repo's root directory // And, will fail since global nuget.config is updated var result = _fixture.RunDotnet(root, string.Join(" ", args), ignoreExitCode: true); // Assert Assert.True(result.ExitCode == 0); // Ensure that no messages are shown with Verbosity as Quiet Assert.Equal(string.Empty, result.Item2); var settings = Settings.LoadDefaultSettings(null, null, null); var packageSourcesSection = settings.GetSection("packageSources"); var sourceItem = packageSourcesSection?.GetFirstItemWithAttribute <SourceItem>("key", "test_source"); Assert.Equal("http://test_source", sourceItem.GetValueAsPath()); } }
public void SourcesCommandTest_AddWithUserNamePassword() { using (var preserver = new NuGet.CommandLine.Test.DefaultConfigurationFilePreserver()) { // Arrange var args = new string[] { "nuget", "add", "source", "http://test_source", "--name", "test_source", "--username", "test_user_name", "--password", "test_password" }; var root = Directory.GetDirectoryRoot(Directory.GetCurrentDirectory()); // Act // Set the working directory to C:\, otherwise, // the test will change the nuget.config at the code repo's root directory // And, will fail since global nuget.config is updated var result = _fixture.RunDotnet(root, string.Join(" ", args), ignoreExitCode: true); // Assert Assert.True(0 == result.Item1, result.Item2 + " " + result.Item3); var settings = Settings.LoadDefaultSettings(null, null, null); var packageSourcesSection = settings.GetSection("packageSources"); var sourceItem = packageSourcesSection?.GetFirstItemWithAttribute <SourceItem>("key", "test_source"); Assert.Equal("http://test_source", sourceItem.GetValueAsPath()); var sourceCredentialsSection = settings.GetSection("packageSourceCredentials"); var credentialItem = sourceCredentialsSection?.Items.First(c => string.Equals(c.ElementName, "test_source", StringComparison.OrdinalIgnoreCase)) as CredentialsItem; Assert.NotNull(credentialItem); Assert.Equal("test_user_name", credentialItem.Username); var password = EncryptionUtility.DecryptString(credentialItem.Password); Assert.Equal("test_password", password); } }