public void ShouldNotSetupApplicationIfAlreadyConfigured([Frozen]Mock<IApplicationConfiguration> applicationConfiguration, [Frozen]Mock<TextWriter> writer, CreateAppCommand command, string[] arguments, string applicationName) { applicationConfiguration.Setup(x => x.GetApplicationId()).Returns(applicationName); command.Execute(arguments); writer.Verify(x => x.WriteLine("This directory is already configured to track application \"{0}\".", applicationName), Times.Once()); }
public void ShouldSetupApplicationLocallyAfterCreationIfNotConfigured([Frozen]Mock<IApplicationConfiguration> applicationConfiguration, [Frozen]Mock<IAppHarborClient> client, CreateAppCommand command, CreateResult result, User user, string[] arguments) { client.Setup(x => x.CreateApplication(It.IsAny<string>(), It.IsAny<string>())).Returns(result); client.Setup(x => x.GetUser()).Returns(user); applicationConfiguration.Setup(x => x.GetApplicationId()).Throws<ApplicationConfigurationException>(); command.Execute(arguments); applicationConfiguration.Verify(x => x.SetupApplication(result.Id, user), Times.Once()); }
public void ShouldThrowWhenNoArguments(CreateAppCommand command) { var exception = Assert.Throws<CommandException>(() => command.Execute(new string[0])); Assert.Equal("An application name must be provided to create an application", exception.Message); }
public void ShouldCreateApplicationWithOnlyName([Frozen]Mock<IAppHarborClient> client, CreateAppCommand command) { var arguments = new string[] { "foo" }; command.Execute(arguments); client.Verify(x => x.CreateApplication(arguments.First(), arguments.Skip(1).FirstOrDefault()), Times.Once()); }