public async Task StoreCommand_ExecuteAsync_CallsHostProvider() { const string testUserName = "******"; const string testPassword = "******"; // [SuppressMessage("Microsoft.Security", "CS001:SecretInline", Justification="Fake credential")] var stdin = $"protocol=http\nhost=example.com\nusername={testUserName}\npassword={testPassword}\n\n"; var expectedInput = new InputArguments(new Dictionary <string, string> { ["protocol"] = "http", ["host"] = "example.com", ["username"] = testUserName, ["password"] = testPassword }); var providerMock = new Mock <IHostProvider>(); providerMock.Setup(x => x.StoreCredentialAsync(It.IsAny <InputArguments>())) .Returns(Task.CompletedTask); var providerRegistry = new TestHostProviderRegistry { Provider = providerMock.Object }; var context = new TestCommandContext { Streams = { In = stdin } }; var command = new StoreCommand(context, providerRegistry); await command.ExecuteAsync(); providerMock.Verify( x => x.StoreCredentialAsync(It.Is <InputArguments>(y => AreInputArgumentsEquivalent(expectedInput, y))), Times.Once); }
public async Task StoreCommand_ExecuteAsync_CallsHostProvider() { const string testUserName = "******"; const string testPassword = "******"; var stdin = $"username={testUserName}\npassword={testPassword}\n\n"; var expectedInput = new InputArguments(new Dictionary <string, string> { ["username"] = testUserName, ["password"] = testPassword }); var providerMock = new Mock <IHostProvider>(); providerMock.Setup(x => x.StoreCredentialAsync(It.IsAny <InputArguments>())) .Returns(Task.CompletedTask); var providerRegistry = new TestHostProviderRegistry { Provider = providerMock.Object }; var context = new TestCommandContext { Streams = { In = stdin } }; string[] cmdArgs = { "store" }; var command = new StoreCommand(providerRegistry); await command.ExecuteAsync(context, cmdArgs); providerMock.Verify( x => x.StoreCredentialAsync(It.Is <InputArguments>(y => AreInputArgumentsEquivalent(expectedInput, y))), Times.Once); }