Ejemplo n.º 1
0
        public async Task ShouldSupportAllShellInstallers(ShellCompletionInstaller 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)));
        }
Ejemplo n.º 2
0
        public async Task ShouldNotWriteToDiskAndWriteToConsoleIfDryRun(ShellCompletionInstaller 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();
        }
Ejemplo n.º 3
0
        public async Task ShouldEnsureProfileDirectoryExists(ShellCompletionInstaller 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);
            }
        }
Ejemplo n.º 4
0
        public async Task ShouldTakeABackup(ShellCompletionInstaller 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);
            }
        }