public void Constructor_CommandAttributesAreInitializedProperly() { // Arrange var userInterface = new Mock<IUserInterface>(); var installationStatusProvider = new Mock<IInstallationStatusProvider>(); // Act var installationStatusCommand = new InstallationStatusCommand(userInterface.Object, installationStatusProvider.Object); // Assert CommandTestUtilities.ValidateCommandAttributes(installationStatusCommand.Attributes); }
public void Constructor_AllParametersAreSet_ObjectIsInstantiated() { // Arrange var userInterface = new Mock<IUserInterface>(); var installationStatusProvider = new Mock<IInstallationStatusProvider>(); // Act var installationStatusCommand = new InstallationStatusCommand(userInterface.Object, installationStatusProvider.Object); // Assert Assert.IsNotNull(installationStatusCommand); }
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_InstallationStatusProviderReturnsPackages_OneMessageForEachPackageIsWrittenToUserInterface() { // Arrange var installationStatusProvider = new Mock<IInstallationStatusProvider>(); var packages = new List<NuDeployPackageInfo> { new NuDeployPackageInfo { Id = "Package.A", Version = new SemanticVersion(1, 0, 0, 1), IsInstalled = true }, new NuDeployPackageInfo { Id = "Package.B", Version = new SemanticVersion(1, 0, 0, 2), IsInstalled = false }, }; installationStatusProvider.Setup(i => i.GetPackageInfo()).Returns(packages); var installationStatusCommand = new InstallationStatusCommand(this.loggingUserInterface.UserInterface, installationStatusProvider.Object); // Act installationStatusCommand.Execute(); // Assert foreach (var packageInfo in packages) { Assert.IsTrue(this.loggingUserInterface.UserInterfaceOutput.Contains(packageInfo.Id)); Assert.IsTrue(this.loggingUserInterface.UserInterfaceOutput.Contains(packageInfo.Version.ToString())); } }
public void Execute_PackageIdSpecified_NoPackagesAreReturned_MessageIsWrittenToUserInterface() { // Arrange string packageId = "Package.A"; var installationStatusProvider = new Mock<IInstallationStatusProvider>(); var packages = new List<NuDeployPackageInfo>(); installationStatusProvider.Setup(i => i.GetPackageInfo(packageId)).Returns(packages); var installationStatusCommand = new InstallationStatusCommand(this.loggingUserInterface.UserInterface, installationStatusProvider.Object); // Act installationStatusCommand.Execute(); // Assert Assert.IsNotNullOrEmpty(this.loggingUserInterface.UserInterfaceOutput); }
public void Execute_NoPackageIdIsSupplied_GeneralGetPackageInfoIsCalled() { // Arrange var installationStatusProvider = new Mock<IInstallationStatusProvider>(); var installationStatusCommand = new InstallationStatusCommand(this.loggingUserInterface.UserInterface, installationStatusProvider.Object); // Act installationStatusCommand.Execute(); // Assert installationStatusProvider.Verify(i => i.GetPackageInfo(), Times.Once()); }
public void Execute_InvalidPackageIdIsSupplied_GeneralGetPackageInfoIsCalled(string packageId) { // Arrange var installationStatusProvider = new Mock<IInstallationStatusProvider>(); var installationStatusCommand = new InstallationStatusCommand(this.loggingUserInterface.UserInterface, installationStatusProvider.Object); // prepare command arguments installationStatusCommand.Arguments.Add(InstallationStatusCommand.ArgumentNameNugetPackageId, packageId); // Act installationStatusCommand.Execute(); // Assert installationStatusProvider.Verify(i => i.GetPackageInfo(), 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 }; }