public void Constructor_CommandAttributesAreInitializedProperly() { // Arrange var userInterface = new Mock<IUserInterface>(); var packageInstaller = new Mock<IPackageInstaller>(); var deploymentTypeParser = new Mock<IDeploymentTypeParser>(); // Act var installCommand = new InstallCommand(userInterface.Object, packageInstaller.Object, deploymentTypeParser.Object); // Assert CommandTestUtilities.ValidateCommandAttributes(installCommand.Attributes); }
public void Constructor_AllParametersAreSet_ObjectIsInstantiated() { // Arrange var userInterface = new Mock<IUserInterface>(); var packageInstaller = new Mock<IPackageInstaller>(); var deploymentTypeParser = new Mock<IDeploymentTypeParser>(); // Act var installCommand = new InstallCommand(userInterface.Object, packageInstaller.Object, deploymentTypeParser.Object); // Assert Assert.IsNotNull(installCommand); }
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_DeploymentTypeIsUnrecognized_InstallIsNotCalled() { // Arrange string packageId = "Package.A"; var userInterface = new Mock<IUserInterface>(); var packageInstaller = new Mock<IPackageInstaller>(); var deploymentTypeParser = new Mock<IDeploymentTypeParser>(); deploymentTypeParser.Setup(d => d.GetDeploymentType(It.IsAny<string>())).Returns(DeploymentType.NotRecognized); var installCommand = new InstallCommand(userInterface.Object, packageInstaller.Object, deploymentTypeParser.Object); // prepare arguments installCommand.Arguments.Add(InstallCommand.ArgumentNameNugetPackageId, packageId); installCommand.Arguments.Add(InstallCommand.ArgumentNameNugetDeploymentType, "SomethingReallyWrong"); // Act installCommand.Execute(); // Assert packageInstaller.Verify(p => p.Install(packageId, It.IsAny<DeploymentType>(), It.IsAny<bool>(), It.IsAny<string[]>(), It.IsAny<string[]>()), Times.Never()); }
public void Execute_TwoSystemSettingTransformationProfilesSupplied_InstallIsCalledWithTwoTransformationProfiles() { // Arrange string packageId = "Package.A"; string deploymentTypeString = "Full"; string systemSettingTransformationProfilesString = "Profile1,Profile2"; var userInterface = new Mock<IUserInterface>(); var packageInstaller = new Mock<IPackageInstaller>(); packageInstaller.Setup( p => p.Install(It.IsAny<string>(), It.IsAny<DeploymentType>(), It.IsAny<bool>(), It.IsAny<string[]>(), It.IsAny<string[]>())).Returns( new SuccessResult()); var deploymentTypeParser = new Mock<IDeploymentTypeParser>(); deploymentTypeParser.Setup(d => d.GetDeploymentType(deploymentTypeString)).Returns(DeploymentType.Full); var installCommand = new InstallCommand(userInterface.Object, packageInstaller.Object, deploymentTypeParser.Object); // prepare arguments installCommand.Arguments.Add(InstallCommand.ArgumentNameNugetPackageId, packageId); installCommand.Arguments.Add(InstallCommand.ArgumentNameNugetDeploymentType, deploymentTypeString); installCommand.Arguments.Add(InstallCommand.ArgumentNameSystemSettingTransformationProfiles, systemSettingTransformationProfilesString); // Act installCommand.Execute(); // Assert packageInstaller.Verify( p => p.Install( It.IsAny<string>(), It.IsAny<DeploymentType>(), It.IsAny<bool>(), It.Is<string[]>(strings => strings.Length == 2 && strings.First().Equals("Profile1") && strings.Last().Equals("Profile2")), It.IsAny<string[]>()), Times.Once()); }
public void Execute_NoValidPackageIdIsSupplied_InstallIsNotExecuted(string packageId) { // Arrange var userInterface = new Mock<IUserInterface>(); var packageInstaller = new Mock<IPackageInstaller>(); var deploymentTypeParser = new Mock<IDeploymentTypeParser>(); var installCommand = new InstallCommand(userInterface.Object, packageInstaller.Object, deploymentTypeParser.Object); // prepare arguments installCommand.Arguments.Add(InstallCommand.ArgumentNameNugetPackageId, packageId); // Act installCommand.Execute(); // Assert packageInstaller.Verify(p => p.Install(It.IsAny<string>(), It.IsAny<DeploymentType>(), It.IsAny<bool>(), It.IsAny<string[]>(), It.IsAny<string[]>()), Times.Never()); }
public void Execute_NoDeploymentTypeSupplied_MessageIsWrittenToUserInterface() { // Arrange string packageId = "Package.A"; var packageInstaller = new Mock<IPackageInstaller>(); var deploymentTypeParser = new Mock<IDeploymentTypeParser>(); var installCommand = new InstallCommand(this.loggingUserInterface.UserInterface, packageInstaller.Object, deploymentTypeParser.Object); // prepare arguments installCommand.Arguments.Add(InstallCommand.ArgumentNameNugetPackageId, packageId); // Act installCommand.Execute(); // Assert Assert.IsNotNullOrEmpty(this.loggingUserInterface.UserInterfaceOutput); }
public void Execute_ForceOptionIsSet_InstallIsCalledWithForceOption() { // Arrange string packageId = "Package.A"; string deploymentTypeString = "Full"; bool expectedForceOptionValue = true; var userInterface = new Mock<IUserInterface>(); var packageInstaller = new Mock<IPackageInstaller>(); packageInstaller.Setup( p => p.Install(It.IsAny<string>(), It.IsAny<DeploymentType>(), It.IsAny<bool>(), It.IsAny<string[]>(), It.IsAny<string[]>())).Returns( new SuccessResult()); var deploymentTypeParser = new Mock<IDeploymentTypeParser>(); deploymentTypeParser.Setup(d => d.GetDeploymentType(deploymentTypeString)).Returns(DeploymentType.Full); var installCommand = new InstallCommand(userInterface.Object, packageInstaller.Object, deploymentTypeParser.Object); // prepare arguments installCommand.Arguments.Add(InstallCommand.ArgumentNameNugetPackageId, packageId); installCommand.Arguments.Add(InstallCommand.ArgumentNameNugetDeploymentType, deploymentTypeString); installCommand.Arguments.Add(NuDeployConstants.CommonCommandOptionNameForce, bool.TrueString); // Act installCommand.Execute(); // Assert packageInstaller.Verify( p => p.Install(It.IsAny<string>(), It.IsAny<DeploymentType>(), expectedForceOptionValue, It.IsAny<string[]>(), It.IsAny<string[]>()), Times.Once()); }
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 }; }