public async Task ExecuteAsync_MultiPartRouteWithBodyFromFile_VerifyResponse() { string filePath = "someFilePath.txt"; string fileContents = "This is a test response from a PATCH: \"Test Patch Body From File\""; ArrangeInputs(commandText: $"PATCH --file " + filePath, baseAddress: _baseAddress, path: _testPath, urlsWithResponse: _urlsWithResponse, out MockedShellState shellState, out HttpState httpState, out ICoreParseResult parseResult, out MockedFileSystem fileSystem, out IPreferences preferences, readBodyFromFile: true, fileContents: fileContents); fileSystem.AddFile(filePath, "Test Patch Body From File"); PatchCommand patchCommand = new PatchCommand(fileSystem, preferences); await patchCommand.ExecuteAsync(shellState, httpState, parseResult, CancellationToken.None); List <string> result = shellState.Output; Assert.Equal(2, result.Count); Assert.Contains("HTTP/1.1 200 OK", result); Assert.Contains(fileContents, result); }
public async Task ExecuteAsync_WithNoBasePath_VerifyError() { ArrangeInputs(commandText: "PATCH", baseAddress: null, path: null, urlsWithResponse: null, out MockedShellState shellState, out HttpState httpState, out ICoreParseResult parseResult, out MockedFileSystem fileSystem, out IPreferences preferences); string expectedErrorMessage = Strings.Error_NoBasePath.SetColor(httpState.ErrorColor); PatchCommand patchCommand = new PatchCommand(fileSystem, preferences); await patchCommand.ExecuteAsync(shellState, httpState, parseResult, CancellationToken.None); Assert.Equal(expectedErrorMessage, shellState.ErrorMessage); }
public async Task ChangePatchVersionTest() { using (var fs = new DisposableFileSystem()) { fs.CreateFile("MySolution.sln"); fs.CreateFolder("src/Services"); fs.CreateFile("src/Services/project1.csproj", ProjectHelper.SetVersion("1.5.1")); var store = new ProjectStore(); var command = new PatchCommand(GitHelper.CreateDefaultGitMock().Object); var context = new CommandContext(_console, Verbosity.Info); context.Directory = fs.RootPath; await command.ExecuteAsync(context); var project = store.Read(PathHelper.GetFile(fs, "src/Services/project1.csproj")); Assert.Equal("1.5.2", project.Version); } }
public async Task ExecuteAsync_MultiPartRouteWithInlineContent_VerifyResponse() { ArrangeInputs(commandText: "PATCH --content \"Test Patch Body\"", baseAddress: _baseAddress, path: _testPath, urlsWithResponse: _urlsWithResponse, out MockedShellState shellState, out HttpState httpState, out ICoreParseResult parseResult, out MockedFileSystem fileSystem, out IPreferences preferences); PatchCommand patchCommand = new PatchCommand(fileSystem, preferences); await patchCommand.ExecuteAsync(shellState, httpState, parseResult, CancellationToken.None); string expectedResponse = "This is a test response from a PATCH: \"Test Patch Body\""; List <string> result = shellState.Output; Assert.Equal(2, result.Count); Assert.Contains("HTTP/1.1 200 OK", result); Assert.Contains(expectedResponse, result); }
public async Task AddFileTest() { using (var fs = new DisposableFileSystem()) { fs.CreateFile("MySolution.sln"); fs.CreateFolder("src/Services"); fs.CreateFile("src/Services/project1.csproj", ProjectHelper.SetVersion("1.5.1")); var store = new ProjectStore(); var gitMock = GitHelper.CreateGitMock(true); var command = new PatchCommand(gitMock.Object); var context = new CommandContext(_console, Verbosity.Info); context.Add = true; context.Directory = fs.RootPath; context.Message = "test"; await command.ExecuteAsync(context); gitMock.Verify(git => git.IsInstalled()); gitMock.Verify(git => git.RunCommandAsync(It.IsAny <CommandContext>(), It.Is <string>(args => args.Equals("add --all")))); gitMock.Verify(git => git.RunCommandAsync(It.IsAny <CommandContext>(), It.Is <string>(args => args.Equals("commit -a -m \"test\"")))); } }