public void Execute_NoPackageIdIsSupplied_InstallIsNotExecuted()
        {
            // Arrange
            var packageUninstaller = new Mock<IPackageUninstaller>();

            var uninstallCommand = new UninstallCommand(this.loggingUserInterface.UserInterface, packageUninstaller.Object);

            // prepare arguments
            uninstallCommand.Arguments = new Dictionary<string, string>();

            // Act
            uninstallCommand.Execute();

            // Assert
            packageUninstaller.Verify(p => p.Uninstall(It.IsAny<string>(), It.IsAny<SemanticVersion>()), Times.Never());
        }
        public void Constructor_AllParametersAreSet_ObjectIsInstantiated()
        {
            // Arrange
            var userInterface = new Mock<IUserInterface>();
            var packageUninstaller = new Mock<IPackageUninstaller>();

            // Act
            var uninstallCommand = new UninstallCommand(userInterface.Object, packageUninstaller.Object);

            // Assert
            Assert.IsNotNull(uninstallCommand);
        }
        public void Constructor_CommandAttributesAreInitializedProperly()
        {
            // Arrange
            var userInterface = new Mock<IUserInterface>();
            var packageUninstaller = new Mock<IPackageUninstaller>();

            // Act
            var uninstallCommand = new UninstallCommand(userInterface.Object, packageUninstaller.Object);

            // Assert
            CommandTestUtilities.ValidateCommandAttributes(uninstallCommand.Attributes);
        }
 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 void Execute_UninstallSucceeds_MessageIsWrittenToUserInterface()
        {
            // Arrange
            string packageId = "Package.A";

            var packageUninstaller = new Mock<IPackageUninstaller>();
            packageUninstaller.Setup(p => p.Uninstall(packageId, It.IsAny<SemanticVersion>())).Returns(new SuccessResult());

            var uninstallCommand = new UninstallCommand(this.loggingUserInterface.UserInterface, packageUninstaller.Object);

            // prepare arguments
            uninstallCommand.Arguments.Add(UninstallCommand.ArgumentNameNugetPackageId, packageId);

            // Act
            uninstallCommand.Execute();

            // Assert
            Assert.IsTrue(this.loggingUserInterface.UserInterfaceOutput.Contains("succeeded") || this.loggingUserInterface.UserInterfaceOutput.Contains("success"));
        }
        public void Execute_PackageIdIsValid_UninstallIsExecuted()
        {
            // Arrange
            var packageUninstaller = new Mock<IPackageUninstaller>();
            packageUninstaller.Setup(p => p.Uninstall(It.IsAny<string>(), It.IsAny<SemanticVersion>())).Returns(new SuccessResult());

            var uninstallCommand = new UninstallCommand(this.loggingUserInterface.UserInterface, packageUninstaller.Object);

            // prepare arguments
            string packageId = "Package.A";
            uninstallCommand.Arguments.Add(UninstallCommand.ArgumentNameNugetPackageId, packageId);

            // Act
            uninstallCommand.Execute();

            // Assert
            packageUninstaller.Verify(p => p.Uninstall(packageId, It.IsAny<SemanticVersion>()), Times.Once());
        }
        public void Execute_NoValidPackageIdIsSupplied_MessageIsWrittenToUserInterface(string packageId)
        {
            // Arrange
            var packageUninstaller = new Mock<IPackageUninstaller>();

            var uninstallCommand = new UninstallCommand(this.loggingUserInterface.UserInterface, packageUninstaller.Object);

            // prepare arguments
            uninstallCommand.Arguments.Add(UninstallCommand.ArgumentNameNugetPackageId, packageId);

            // Act
            uninstallCommand.Execute();

            // Assert
            Assert.IsNotNullOrEmpty(this.loggingUserInterface.UserInterfaceOutput);
        }
        public void Execute_NoPackageIdIsSupplied_MessageIsWrittenToUserInterface()
        {
            // Arrange
            var packageUninstaller = new Mock<IPackageUninstaller>();

            var uninstallCommand = new UninstallCommand(this.loggingUserInterface.UserInterface, packageUninstaller.Object);

            // prepare arguments
            uninstallCommand.Arguments = new Dictionary<string, string>();

            // Act
            uninstallCommand.Execute();

            // Assert
            Assert.IsNotNullOrEmpty(this.loggingUserInterface.UserInterfaceOutput);
        }
        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
                };
        }