public void ShouldInitializeRepositoryIfUserWantIt([Frozen]Mock<IFileSystem> fileSystem, [Frozen]Mock<TextReader> reader, [Frozen]Mock<TextWriter> writer, [Frozen]Mock<IGitCommand> gitCommand, GitRepositoryConfigurer repositoryConfigurer, string id, User user)
{
gitCommand.Setup(x => x.Execute("status")).Throws<GitCommandException>();
reader.Setup(x => x.ReadLine()).Returns("y");
var gitIgnoreFile = Path.Combine(Directory.GetCurrentDirectory(), ".gitignore");
Action<MemoryStream> VerifyGitIgnoreContent = stream =>
Assert.Equal(Encoding.Default.GetBytes(GitRepositoryConfigurer.DefaultGitIgnore), stream.ToArray());
using (var stream = new DelegateOutputStream(VerifyGitIgnoreContent))
{
fileSystem.Setup(x => x.OpenWrite(gitIgnoreFile)).Returns(stream);
repositoryConfigurer.Configure(id, user);
}
fileSystem.Verify(x => x.OpenWrite(gitIgnoreFile), Times.Once());
gitCommand.Verify(x => x.Execute("init"), Times.Once());
writer.Verify(x => x.WriteLine("Git repository was initialized with default .gitignore file."));
}