public async Task HandleShouldWriteMergedGitignoreFileWhenCalledWithMultipleNames() { // Arrange const string gitignoreFilenames = "test.gitignore,test2.gitignore"; // Separator as in split stub const string gitignoreContent = "test content # ./[*]"; const string destination = "C:/test"; const string expectedContent = gitignoreContent + gitignoreContent; // As in merge stub var githubServiceStub = new GitignoreServiceStub(gitignoreContent); var fileWriterMock = new Mock <IGitignoreFileWriter>(); fileWriterMock .Setup(writer => writer.WriteToFileAsync(It.IsAny <string>(), It.IsAny <string>())) .Returns(Task.CompletedTask) .Verifiable(); var(command, handler) = CreateCommandAndHandler(githubServiceStub, fileWriterMock.Object); command.InitOptions(gitignoreFilenames, destination); // Act var result = await handler.HandleCommandAsync(command); // Assert result .Should() .Be(ReturnCodes.Success); fileWriterMock.Verify(writer => writer.WriteToFileAsync(destination, expectedContent), Times.Once); }
public async Task HandleShouldWriteGitignoreFileWhenSuccessful() { // Arrange const string gitignoreFilename = "test.gitignore"; const string gitignoreContent = "test content # ./[*]"; const string destination = "C:/test"; var githubServiceStub = new GitignoreServiceStub(gitignoreContent); var fileWriterMock = new Mock <IGitignoreFileWriter>(); fileWriterMock .Setup(writer => writer.WriteToFileAsync(It.IsAny <string>(), It.IsAny <string>())) .Returns(Task.CompletedTask) .Verifiable(); var(command, handler) = CreateCommandAndHandler(githubServiceStub, fileWriterMock.Object); command.InitOptions(gitignoreFilename, destination); // Act var result = await handler.HandleCommandAsync(command); // Assert result .Should() .Be(ReturnCodes.Success); fileWriterMock.Verify(writer => writer.WriteToFileAsync(destination, gitignoreContent), Times.Once); }