public async Task ShouldSupportAllShellInstallers(IShellCompletionInstaller installer) { await installAutoCompleteCommand.Execute(new[] { $"--shell={installer.SupportedShell.ToString()}" }); var zshProfile = installer.ProfileLocation; fileSystem.Received() .OverwriteFile(zshProfile, Arg.Is <string>(arg => arg.Contains(installer.ProfileScript))); }
public async Task ShouldNotWriteToDiskAndWriteToConsoleIfDryRun(IShellCompletionInstaller installer) { await installAutoCompleteCommand.Execute(new[] { $"--shell={installer.SupportedShell.ToString()}", "--dryRun" }); fileSystem.DidNotReceive() .OverwriteFile(installer.ProfileLocation, Arg.Is <string>(arg => arg.Contains(installer.ProfileScript))); commandOutputProvider.Received() .Information(Arg.Is <string>(arg => arg.Contains(installer.ProfileScript))); fileSystem.ClearReceivedCalls(); commandOutputProvider.ClearReceivedCalls(); }
public async Task ShouldEnsureProfileDirectoryExists(IShellCompletionInstaller installer) { SetupMockNoProfileFile(); await installAutoCompleteCommand.Execute(new[] { $"--shell={installer.SupportedShell.ToString()}" }); fileSystem.Received() .EnsureDirectoryExists(Path.GetDirectoryName(installer.ProfileLocation)); void SetupMockNoProfileFile() { fileSystem.FileExists(installer.ProfileLocation).Returns(false); } }
public async Task ShouldTakeABackup(IShellCompletionInstaller installer) { SetupMockExistingProfileFile(); await installAutoCompleteCommand.Execute(new[] { $"--shell={installer.SupportedShell.ToString()}" }); fileSystem.Received() .CopyFile(installer.ProfileLocation, installer.ProfileLocation + ".orig"); void SetupMockExistingProfileFile() { fileSystem.FileExists(installer.ProfileLocation).Returns(true); } }