public void Constructor_AllParametersAreSet_ObjectIsInstantiated() { // Arrange var userInterface = new Mock<IUserInterface>(); var repositoryConfigurationCommandActionParser = new Mock<IRepositoryConfigurationCommandActionParser>(); var sourceRepositoryProvider = new Mock<ISourceRepositoryProvider>(); // Act var repositorySourceConfigurationCommand = new RepositorySourceConfigurationCommand( userInterface.Object, repositoryConfigurationCommandActionParser.Object, sourceRepositoryProvider.Object); // Assert Assert.IsNotNull(repositorySourceConfigurationCommand); }
public void Constructor_CommandAttributesAreInitializedProperly() { // Arrange var userInterface = new Mock<IUserInterface>(); var repositoryConfigurationCommandActionParser = new Mock<IRepositoryConfigurationCommandActionParser>(); var sourceRepositoryProvider = new Mock<ISourceRepositoryProvider>(); // Act var repositorySourceConfigurationCommand = new RepositorySourceConfigurationCommand( userInterface.Object, repositoryConfigurationCommandActionParser.Object, sourceRepositoryProvider.Object); // Assert CommandTestUtilities.ValidateCommandAttributes(repositorySourceConfigurationCommand.Attributes); }
public void Execute_ActionArgumentIs_Unrecognized_MessageIsWrittenToUserInterface() { // Arrange var commandAction = RepositoryConfigurationCommandAction.Unrecognized; var repositoryConfigurationCommandActionParser = new Mock<IRepositoryConfigurationCommandActionParser>(); repositoryConfigurationCommandActionParser.Setup(r => r.ParseAction(It.IsAny<string>())).Returns(commandAction); var sourceRepositoryProvider = new Mock<ISourceRepositoryProvider>(); var repositorySourceConfigurationCommand = new RepositorySourceConfigurationCommand( this.loggingUserInterface.UserInterface, repositoryConfigurationCommandActionParser.Object, sourceRepositoryProvider.Object); // prepare command arguments repositorySourceConfigurationCommand.Arguments = new Dictionary<string, string>(); // Act repositorySourceConfigurationCommand.Execute(); // Assert Assert.IsNotNullOrEmpty(this.loggingUserInterface.UserInterfaceOutput); }
public void Execute_ActionArgumentIs_Reset_ResetRepositoryConfigurationSucceeds_MessageIsWrittenToUserInterface() { // Arrange var commandAction = RepositoryConfigurationCommandAction.Reset; var repositoryConfigurationCommandActionParser = new Mock<IRepositoryConfigurationCommandActionParser>(); repositoryConfigurationCommandActionParser.Setup(r => r.ParseAction(It.IsAny<string>())).Returns(commandAction); var sourceRepositoryProvider = new Mock<ISourceRepositoryProvider>(); sourceRepositoryProvider.Setup(s => s.ResetRepositoryConfiguration()).Returns(new SuccessResult()); var repositorySourceConfigurationCommand = new RepositorySourceConfigurationCommand( this.loggingUserInterface.UserInterface, repositoryConfigurationCommandActionParser.Object, sourceRepositoryProvider.Object); // Act repositorySourceConfigurationCommand.Execute(); // Assert Assert.IsTrue(this.loggingUserInterface.UserInterfaceOutput.Contains("success") || this.loggingUserInterface.UserInterfaceOutput.Contains("succeed")); }
public void Execute_ActionArgumentIs_Reset_ResetRepositoryConfigurationIsCalled() { // Arrange var commandAction = RepositoryConfigurationCommandAction.Reset; var repositoryConfigurationCommandActionParser = new Mock<IRepositoryConfigurationCommandActionParser>(); repositoryConfigurationCommandActionParser.Setup(r => r.ParseAction(It.IsAny<string>())).Returns(commandAction); var sourceRepositoryProvider = new Mock<ISourceRepositoryProvider>(); sourceRepositoryProvider.Setup(s => s.ResetRepositoryConfiguration()).Returns(new SuccessResult()); var repositorySourceConfigurationCommand = new RepositorySourceConfigurationCommand( this.loggingUserInterface.UserInterface, repositoryConfigurationCommandActionParser.Object, sourceRepositoryProvider.Object); // Act repositorySourceConfigurationCommand.Execute(); // Assert sourceRepositoryProvider.Verify(s => s.ResetRepositoryConfiguration(), Times.Once()); }
public void Execute_ActionArgumentIs_List_NoRepositoriesConfigured_MessageIsWrittenToUserInterface() { // Arrange var commandAction = RepositoryConfigurationCommandAction.List; var repositoryConfigurationCommandActionParser = new Mock<IRepositoryConfigurationCommandActionParser>(); repositoryConfigurationCommandActionParser.Setup(r => r.ParseAction(It.IsAny<string>())).Returns(commandAction); var sourceRepositoryProvider = new Mock<ISourceRepositoryProvider>(); var configurations = new List<SourceRepositoryConfiguration>(); sourceRepositoryProvider.Setup(s => s.GetRepositoryConfigurations()).Returns(configurations); var repositorySourceConfigurationCommand = new RepositorySourceConfigurationCommand( this.loggingUserInterface.UserInterface, repositoryConfigurationCommandActionParser.Object, sourceRepositoryProvider.Object); // Act repositorySourceConfigurationCommand.Execute(); // Assert Assert.IsNotNullOrEmpty(this.loggingUserInterface.UserInterfaceOutput); }
public void Execute_ActionArgumentIs_List_AllConfiguredRepositoriesAreListed() { // Arrange var commandAction = RepositoryConfigurationCommandAction.List; var repositoryConfigurationCommandActionParser = new Mock<IRepositoryConfigurationCommandActionParser>(); repositoryConfigurationCommandActionParser.Setup(r => r.ParseAction(It.IsAny<string>())).Returns(commandAction); var sourceRepositoryProvider = new Mock<ISourceRepositoryProvider>(); var configurations = new List<SourceRepositoryConfiguration> { new SourceRepositoryConfiguration { Name = "Test Repo 1", Url = new Uri("http://test.repo1.com/api/v2") }, new SourceRepositoryConfiguration { Name = "Test Repo 2", Url = new Uri("http://test.repo2.com/api/v2") }, new SourceRepositoryConfiguration { Name = "Test Repo 3", Url = new Uri("http://test.repo3.com/api/v2") } }; sourceRepositoryProvider.Setup(s => s.GetRepositoryConfigurations()).Returns(configurations); var repositorySourceConfigurationCommand = new RepositorySourceConfigurationCommand( this.loggingUserInterface.UserInterface, repositoryConfigurationCommandActionParser.Object, sourceRepositoryProvider.Object); // Act repositorySourceConfigurationCommand.Execute(); // Assert foreach (var repositoryConfiguration in configurations) { Assert.IsTrue(this.loggingUserInterface.UserInterfaceOutput.Contains(repositoryConfiguration.Name)); Assert.IsTrue(this.loggingUserInterface.UserInterfaceOutput.Contains(repositoryConfiguration.Url.ToString())); } }
public void Execute_ActionArgumentIs_Delete_NoArgumentsSupplied_DeleteRepositoryConfigurationIsNotCalled() { // Arrange var commandAction = RepositoryConfigurationCommandAction.Delete; var repositoryConfigurationCommandActionParser = new Mock<IRepositoryConfigurationCommandActionParser>(); repositoryConfigurationCommandActionParser.Setup(r => r.ParseAction(It.IsAny<string>())).Returns(commandAction); var sourceRepositoryProvider = new Mock<ISourceRepositoryProvider>(); var repositorySourceConfigurationCommand = new RepositorySourceConfigurationCommand( this.loggingUserInterface.UserInterface, repositoryConfigurationCommandActionParser.Object, sourceRepositoryProvider.Object); // prepare command arguments repositorySourceConfigurationCommand.Arguments = new Dictionary<string, string>(); // Act repositorySourceConfigurationCommand.Execute(); // Assert sourceRepositoryProvider.Verify(s => s.DeleteRepositoryConfiguration(It.IsAny<string>()), Times.Never()); }
public void Execute_ActionArgumentIs_Add_SaveRepositoryConfigurationSucceeds_MessageIsWrittenToUserInterface() { // Arrange var commandAction = RepositoryConfigurationCommandAction.Add; string repositoryName = "Test Repository"; string repositoryUrl = "http://nuget.org/api/v2"; var repositoryConfigurationCommandActionParser = new Mock<IRepositoryConfigurationCommandActionParser>(); repositoryConfigurationCommandActionParser.Setup(r => r.ParseAction(It.IsAny<string>())).Returns(commandAction); var sourceRepositoryProvider = new Mock<ISourceRepositoryProvider>(); sourceRepositoryProvider.Setup(s => s.SaveRepositoryConfiguration(repositoryName, repositoryUrl)).Returns(new SuccessResult()); var repositorySourceConfigurationCommand = new RepositorySourceConfigurationCommand( this.loggingUserInterface.UserInterface, repositoryConfigurationCommandActionParser.Object, sourceRepositoryProvider.Object); // prepare command arguments repositorySourceConfigurationCommand.Arguments.Add(RepositorySourceConfigurationCommand.ArgumentNameRepositoryName, repositoryName); repositorySourceConfigurationCommand.Arguments.Add(RepositorySourceConfigurationCommand.ArgumentNameRepositoryUrl, repositoryUrl); // Act repositorySourceConfigurationCommand.Execute(); // Assert Assert.IsTrue(this.loggingUserInterface.UserInterfaceOutput.Contains("success") || this.loggingUserInterface.UserInterfaceOutput.Contains("suceeded")); }
public void Execute_ActionArgumentIs_Delete_DeleteRepositoryConfigurationSucceeds_MessageIsWrittenToUserInterface() { // Arrange string repositoryName = "Test Repository"; var commandAction = RepositoryConfigurationCommandAction.Delete; var repositoryConfigurationCommandActionParser = new Mock<IRepositoryConfigurationCommandActionParser>(); repositoryConfigurationCommandActionParser.Setup(r => r.ParseAction(It.IsAny<string>())).Returns(commandAction); var sourceRepositoryProvider = new Mock<ISourceRepositoryProvider>(); sourceRepositoryProvider.Setup(s => s.DeleteRepositoryConfiguration(repositoryName)).Returns(new SuccessResult()); var repositorySourceConfigurationCommand = new RepositorySourceConfigurationCommand( this.loggingUserInterface.UserInterface, repositoryConfigurationCommandActionParser.Object, sourceRepositoryProvider.Object); // prepare command arguments repositorySourceConfigurationCommand.Arguments.Add(RepositorySourceConfigurationCommand.ArgumentNameRepositoryName, repositoryName); // Act repositorySourceConfigurationCommand.Execute(); // Assert Assert.IsNotNullOrEmpty(this.loggingUserInterface.UserInterfaceOutput); }
public void Execute_ActionArgumentIs_Add_RepositoryUrlArgumentMissing_SaveRepositoryConfigurationIsNotExecuted() { // Arrange var commandAction = RepositoryConfigurationCommandAction.Add; var repositoryConfigurationCommandActionParser = new Mock<IRepositoryConfigurationCommandActionParser>(); repositoryConfigurationCommandActionParser.Setup(r => r.ParseAction(It.IsAny<string>())).Returns(commandAction); var sourceRepositoryProvider = new Mock<ISourceRepositoryProvider>(); var repositorySourceConfigurationCommand = new RepositorySourceConfigurationCommand( this.loggingUserInterface.UserInterface, repositoryConfigurationCommandActionParser.Object, sourceRepositoryProvider.Object); // prepare command arguments string repositoryName = "Test Repository"; repositorySourceConfigurationCommand.Arguments.Add(RepositorySourceConfigurationCommand.ArgumentNameRepositoryName, repositoryName); // Act repositorySourceConfigurationCommand.Execute(); // Assert sourceRepositoryProvider.Verify(s => s.SaveRepositoryConfiguration(It.IsAny<string>(), It.IsAny<string>()), Times.Never()); }
public void Execute_ActionArgumentIsSet_ArgumentIsPassedToCommandActionParser(string actionParameter) { // Arrange var repositoryConfigurationCommandActionParser = new Mock<IRepositoryConfigurationCommandActionParser>(); var sourceRepositoryProvider = new Mock<ISourceRepositoryProvider>(); var repositorySourceConfigurationCommand = new RepositorySourceConfigurationCommand( this.loggingUserInterface.UserInterface, repositoryConfigurationCommandActionParser.Object, sourceRepositoryProvider.Object); // prepare command arguments repositorySourceConfigurationCommand.Arguments.Add(RepositorySourceConfigurationCommand.ArgumentNameAction, actionParameter); // Act repositorySourceConfigurationCommand.Execute(); // Assert repositoryConfigurationCommandActionParser.Verify(p => p.ParseAction(actionParameter), Times.Once()); }
public void Execute_ActionArgumentIsNotSet_EmptyStringIsPassedToCommandActionParser() { // Arrange var repositoryConfigurationCommandActionParser = new Mock<IRepositoryConfigurationCommandActionParser>(); var sourceRepositoryProvider = new Mock<ISourceRepositoryProvider>(); var repositorySourceConfigurationCommand = new RepositorySourceConfigurationCommand( this.loggingUserInterface.UserInterface, repositoryConfigurationCommandActionParser.Object, sourceRepositoryProvider.Object); // prepare command arguments repositorySourceConfigurationCommand.Arguments = new Dictionary<string, string>(); // Act repositorySourceConfigurationCommand.Execute(); // Assert repositoryConfigurationCommandActionParser.Verify(p => p.ParseAction(string.Empty), Times.Once()); }
public void Setup() { this.userInterface = new Mock<IUserInterface>().Object; this.installationStatus = new InstallationStatusCommand(this.userInterface, new Mock<IInstallationStatusProvider>().Object); this.install = new InstallCommand(this.userInterface, new Mock<IPackageInstaller>().Object, new Mock<IDeploymentTypeParser>().Object); this.uninstall = new UninstallCommand(this.userInterface, new Mock<IPackageUninstaller>().Object); this.cleanup = new CleanupCommand(this.userInterface, new Mock<ICleanupService>().Object); this.packageSolution = new PackageSolutionCommand(this.userInterface, new Mock<ISolutionPackagingService>().Object, new Mock<IBuildPropertyParser>().Object, new Mock<IPublishingService>().Object); this.packageBuildOutput = new PackageBuildOutputCommand(this.userInterface, new Mock<IBuildOutputPackagingService>().Object, new Mock<IPublishingService>().Object); this.configureSources = new RepositorySourceConfigurationCommand(this.userInterface, new Mock<IRepositoryConfigurationCommandActionParser>().Object, new Mock<ISourceRepositoryProvider>().Object); this.configurePublishingTargets = new PublishingTargetConfigurationCommand(this.userInterface, new Mock<IPublishingTargetConfigurationCommandActionParser>().Object, new Mock<IPublishConfigurationAccessor>().Object); this.selfUpdate = new SelfUpdateCommand(new ApplicationInformation(), new Mock<ISelfUpdateService>().Object, new Mock<_Assembly>().Object); this.publishCommand = new PublishCommand(this.userInterface, new Mock<IPublishingService>().Object); this.help = new HelpCommand(new Mock<IHelpProvider>().Object); }
public ConsoleCommandProvider(InstallationStatusCommand installationStatus, InstallCommand install, UninstallCommand uninstall, CleanupCommand cleanup, PackageSolutionCommand packageSolution, PackageBuildOutputCommand packageBuildOutput, RepositorySourceConfigurationCommand configureSources, PublishingTargetConfigurationCommand configurePublishingTargets, SelfUpdateCommand selfUpdate, PublishCommand publishCommand, IHelpCommand helpCommand) { if (installationStatus == null) { throw new ArgumentNullException("installationStatus"); } if (install == null) { throw new ArgumentNullException("install"); } if (uninstall == null) { throw new ArgumentNullException("uninstall"); } if (cleanup == null) { throw new ArgumentNullException("cleanup"); } if (packageSolution == null) { throw new ArgumentNullException("packageSolution"); } if (packageBuildOutput == null) { throw new ArgumentNullException("packageBuildOutput"); } if (configureSources == null) { throw new ArgumentNullException("configureSources"); } if (configurePublishingTargets == null) { throw new ArgumentNullException("configurePublishingTargets"); } if (selfUpdate == null) { throw new ArgumentNullException("selfUpdate"); } if (publishCommand == null) { throw new ArgumentNullException("publishCommand"); } if (helpCommand == null) { throw new ArgumentNullException("helpCommand"); } this.commands = new List<ICommand> { installationStatus, install, uninstall, cleanup, packageSolution, packageBuildOutput, configureSources, configurePublishingTargets, selfUpdate, publishCommand, helpCommand }; }