public void Constructor_AllParametersAreSet_ObjectIsInstantiated()
        {
            // Arrange
            var applicationInformation = new ApplicationInformation();
            var selfUpdateService = new Mock<ISelfUpdateService>();
            var targetAssembly = new Mock<_Assembly>();

            // Act
            var selfupdateCommand = new SelfUpdateCommand(applicationInformation, selfUpdateService.Object, targetAssembly.Object);

            // Assert
            Assert.IsNotNull(selfupdateCommand);
        }
        public void Constructor_CommandAttributesAreInitializedProperly()
        {
            // Arrange
            var applicationInformation = new ApplicationInformation();
            var selfUpdateService = new Mock<ISelfUpdateService>();
            var targetAssembly = new Mock<_Assembly>();

            // Act
            var selfupdateCommand = new SelfUpdateCommand(applicationInformation, selfUpdateService.Object, targetAssembly.Object);

            // Assert
            CommandTestUtilities.ValidateCommandAttributes(selfupdateCommand.Attributes);
        }
        public void Constructor_SelfUpdateIsCalled()
        {
            // Arrange
            var applicationInformation = new ApplicationInformation();
            var selfUpdateService = new Mock<ISelfUpdateService>();
            var targetAssembly = new Mock<_Assembly>();

            string assemblyPath = @"C:\assembly.dll";
            var assemblyVersion = new Version(1, 0, 0);
            var assemblyName = new AssemblyName("jkjdkjas") { Version = assemblyVersion };

            targetAssembly.Setup(a => a.Location).Returns(assemblyPath);
            targetAssembly.Setup(a => a.GetName()).Returns(assemblyName);

            var selfupdateCommand = new SelfUpdateCommand(applicationInformation, selfUpdateService.Object, targetAssembly.Object);

            // Act
            selfupdateCommand.Execute();

            // Assert
            selfUpdateService.Verify(s => s.SelfUpdate(It.IsAny<string>(), It.IsAny<Version>()), 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
                };
        }