public void ShouldCreateAppHarborConfigurationFileIfGitSetupFailed([Frozen]Mock<IGitRepositoryConfigurer> repositoryConfigurer, [Frozen]Mock<IFileSystem> fileSystem, ApplicationConfiguration applicationConfiguration, string id, User user) { repositoryConfigurer.Setup(x => x.Configure(It.IsAny<string>(), It.IsAny<User>())).Throws<RepositoryConfigurationException>(); Action<MemoryStream> VerifyConfigurationContent = stream => Assert.Equal(Encoding.Default.GetBytes(id), stream.ToArray()); using (var stream = new DelegateOutputStream(VerifyConfigurationContent)) { fileSystem.Setup(x => x.OpenWrite(ConfigurationFile)).Returns(stream); applicationConfiguration.SetupApplication(id, user); } fileSystem.Verify(x => x.OpenWrite(ConfigurationFile), Times.Once()); }
public void ShouldCreateAppHarborConfigurationFileIfGitSetupFailed([Frozen] Mock <IGitRepositoryConfigurer> repositoryConfigurer, [Frozen] Mock <IFileSystem> fileSystem, ApplicationConfiguration applicationConfiguration, string id, User user) { repositoryConfigurer.Setup(x => x.Configure(It.IsAny <string>(), It.IsAny <User>())).Throws <RepositoryConfigurationException>(); Action <MemoryStream> VerifyConfigurationContent = stream => Assert.Equal(Encoding.Default.GetBytes(id), stream.ToArray()); using (var stream = new DelegateOutputStream(VerifyConfigurationContent)) { fileSystem.Setup(x => x.OpenWrite(ConfigurationFile)).Returns(stream); applicationConfiguration.SetupApplication(id, user); } fileSystem.Verify(x => x.OpenWrite(ConfigurationFile), Times.Once()); }
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.")); }
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.")); }