public void Constructor_CommandAttributesAreInitializedProperly()
        {
            // Arrange
            var userInterface = new Mock<IUserInterface>();
            var cleanupService = new Mock<ICleanupService>();

            // Act
            var cleanupCommand = new CleanupCommand(userInterface.Object, cleanupService.Object);

            // Assert
            CommandTestUtilities.ValidateCommandAttributes(cleanupCommand.Attributes);
        }
        public void Constructor_AllParametersAreSet_ObjectIsInstantiated()
        {
            // Arrange
            var userInterface = new Mock<IUserInterface>();
            var cleanupService = new Mock<ICleanupService>();

            // Act
            var cleanupCommand = new CleanupCommand(userInterface.Object, cleanupService.Object);

            // Assert
            Assert.IsNotNull(cleanupCommand);
        }
        public void Execute_NoValidPackageIdIsSupplied_GenealCleanupIsCalled(string packageId)
        {
            // Arrange
            var userInterface = new Mock<IUserInterface>();
            var cleanupService = new Mock<ICleanupService>();
            cleanupService.Setup(c => c.Cleanup()).Returns(new SuccessResult());

            var cleanupCommand = new CleanupCommand(userInterface.Object, cleanupService.Object);

            cleanupCommand.Arguments.Add(CleanupCommand.ArgumentNameNugetPackageId, packageId);

            // Act
            cleanupCommand.Execute();

            // Assert
            cleanupService.Verify(c => c.Cleanup(), Times.Once());
        }
        public void Execute_PackageIdIsSupplied_PackageSpecificCleanupIsCalled()
        {
            // Arrange
            string packageId = "Package.A";

            var userInterface = new Mock<IUserInterface>();
            var cleanupService = new Mock<ICleanupService>();
            cleanupService.Setup(c => c.Cleanup(It.IsAny<string>())).Returns(new SuccessResult());

            var cleanupCommand = new CleanupCommand(userInterface.Object, cleanupService.Object);

            cleanupCommand.Arguments.Add(CleanupCommand.ArgumentNameNugetPackageId, packageId);

            // Act
            cleanupCommand.Execute();

            // Assert
            cleanupService.Verify(c => c.Cleanup(packageId), 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
                };
        }