public Program(ApplicationInformation applicationInformation, IUserInterface userInterface, IActionLogger logger, ICommandLineArgumentInterpreter commandLineArgumentInterpreter, IHelpCommand helpCommand) { if (applicationInformation == null) { throw new ArgumentNullException("applicationInformation"); } if (userInterface == null) { throw new ArgumentNullException("userInterface"); } if (logger == null) { throw new ArgumentNullException("logger"); } if (commandLineArgumentInterpreter == null) { throw new ArgumentNullException("commandLineArgumentInterpreter"); } if (helpCommand == null) { throw new ArgumentNullException("helpCommand"); } this.applicationInformation = applicationInformation; this.userInterface = userInterface; this.logger = logger; this.commandLineArgumentInterpreter = commandLineArgumentInterpreter; this.helpCommand = helpCommand; }
public void AddOrUpdatePublishConfiguration_ConfigDoesNotYetExist_NewEntryIsPersisted() { // Arrange string configurationName = "Some Config Name"; string publishLocation = "http://nuget.org/api/v2"; string apiKey = Guid.NewGuid().ToString(); var applicationInformation = new ApplicationInformation { ConfigurationFileFolder = Environment.CurrentDirectory }; var publishConfigurationFactory = new Mock<IPublishConfigurationFactory>(); var publishConfigurationPersistence = new Mock<IFilesystemPersistence<PublishConfiguration[]>>(); var createdPublishConfiguration = new PublishConfiguration { Name = configurationName, PublishLocation = publishLocation, ApiKey = apiKey }; publishConfigurationFactory.Setup(p => p.GetPublishConfiguration(configurationName, publishLocation, apiKey)).Returns(createdPublishConfiguration); var existingConfigurations = new PublishConfiguration[] { }; publishConfigurationPersistence.Setup(p => p.Load(It.IsAny<string>())).Returns(existingConfigurations); var configFilePublishConfigurationAccessor = new ConfigFilePublishConfigurationAccessor( applicationInformation, publishConfigurationFactory.Object, publishConfigurationPersistence.Object); // Act configFilePublishConfigurationAccessor.AddOrUpdatePublishConfiguration(configurationName, publishLocation, apiKey); // Assert publishConfigurationPersistence.Verify( p => p.Save(It.Is<PublishConfiguration[]>(configs => configs.First().Equals(createdPublishConfiguration)), It.IsAny<string>()), Times.Once()); }
public void Constructor_AllParametersAreSet_ObjectIsInstantiated() { // Arrange var applicationInformation = new ApplicationInformation(); var filesystemAccessor = new Mock<IFilesystemAccessor>(); var packageConfigurationAccessor = new Mock<IPackageConfigurationAccessor>(); var packageRepositoryBrowser = new Mock<IPackageRepositoryBrowser>(); var powerShellExecutor = new Mock<IPowerShellExecutor>(); var installationLogicProvider = new Mock<IInstallationLogicProvider>(); var packageUninstaller = new Mock<IPackageUninstaller>(); var nugetPackageExtractor = new Mock<INugetPackageExtractor>(); var packageConfigurationTransformationService = new Mock<IPackageConfigurationTransformationService>(); var configurationFileTransformationService = new Mock<IConfigurationFileTransformationService>(); // Act var packageInstaller = new PackageInstaller( applicationInformation, filesystemAccessor.Object, packageConfigurationAccessor.Object, packageRepositoryBrowser.Object, powerShellExecutor.Object, installationLogicProvider.Object, packageUninstaller.Object, nugetPackageExtractor.Object, packageConfigurationTransformationService.Object, configurationFileTransformationService.Object); // Assert Assert.IsNotNull(packageInstaller); }
public SelfUpdateService(IUserInterface userInterface, ApplicationInformation applicationInformation, IPackageRepositoryBrowser packageRepositoryBrowser, IFilesystemAccessor filesystemAccessor) { if (userInterface == null) { throw new ArgumentNullException("userInterface"); } if (applicationInformation == null) { throw new ArgumentNullException("applicationInformation"); } if (packageRepositoryBrowser == null) { throw new ArgumentNullException("packageRepositoryBrowser"); } if (filesystemAccessor == null) { throw new ArgumentNullException("filesystemAccessor"); } this.userInterface = userInterface; this.applicationInformation = applicationInformation; this.packageRepositoryBrowser = packageRepositoryBrowser; this.filesystemAccessor = filesystemAccessor; }
public ActionLogger(ApplicationInformation applicationInformation, IEncodingProvider encodingProvider) { this.applicationInformation = applicationInformation; this.logfileEncoding = encodingProvider.GetEncoding(); this.logfilPath = this.GetLogfilePath(); this.InitializeLogFile(); }
public void Constructor_UserInterfaceParametersIsNotSet_ArgumentNullExceptionIsThrown() { // Arrange var applicationInformation = new ApplicationInformation(); // Act new HelpProvider(applicationInformation, null); }
public void Constructor_FilesystemAccessorParameterIsNull_ArgumentNullExceptionIsThrown() { // Arrange var applicationInformation = new ApplicationInformation(); IFilesystemAccessor filesystemAccessor = null; // Act new PackagingFolderPathProvider(applicationInformation, filesystemAccessor); }
public void Constructor_SourceRepositoryConfigurationFactoryParametersIsNotSet_ArgumentNullExceptionIsThrown() { // Arrange var applicationInformation = new ApplicationInformation(); var filesystemPersistence = new Mock<IFilesystemPersistence<SourceRepositoryConfiguration[]>>(); // Act new ConfigFileSourceRepositoryProvider(applicationInformation, null, filesystemPersistence.Object); }
public static void RemoveAllFilesAndFoldersWhichAreCreatedOnStartup(ApplicationInformation applicationInformation) { DeleteFolder(applicationInformation.LogFolder); DeleteFolder(applicationInformation.BuildFolder); DeleteFolder(applicationInformation.PrePackagingFolder); DeleteFolder(applicationInformation.PackagingFolder); DeleteFiles("NuDeploy.*.config", applicationInformation.ConfigurationFileFolder); }
public void Constructor_PackageConfigurationAccessorParameterIsNull_ArgumentNullExceptionIsThrown() { // Arrange var applicationInformation = new ApplicationInformation(); IPackageConfigurationAccessor packageConfigurationAccessor = null; IFilesystemAccessor filesystemAccessor = new Mock<IFilesystemAccessor>().Object; // Act new InstallationStatusProvider(applicationInformation, packageConfigurationAccessor, filesystemAccessor); }
public void Constructor_UserInterfaceParametersIsNotSet_ArgumentNullExceptionIsThrown() { // Arrange var applicationInformation = new ApplicationInformation(); var packageRepositoryBrowser = new Mock<IPackageRepositoryBrowser>(); var filesystemAccessor = new Mock<IFilesystemAccessor>(); // Act new SelfUpdateService(null, applicationInformation, packageRepositoryBrowser.Object, filesystemAccessor.Object); }
public void Constructor_HelpCommandParameterIsNotSet_ArgumentNullExceptionIsThrown() { // Arrange var applicationInformation = new ApplicationInformation(); var userInterface = new Mock<IUserInterface>(); var logger = new Mock<IActionLogger>(); var commandLineArgumentInterpreter = new Mock<ICommandLineArgumentInterpreter>(); // Act new Program(applicationInformation, userInterface.Object, logger.Object, commandLineArgumentInterpreter.Object, null); }
public void Constructor_AllParametersAreSet_ObjectIsInstantiated() { // Arrange var applicationInformation = new ApplicationInformation(); var userInterface = new Mock<IUserInterface>(); // Act var helpProvider = new HelpProvider(applicationInformation, userInterface.Object); // Assert Assert.IsNotNull(helpProvider); }
public void Constructor_AllParametersAreSet_ObjectIsInstantiated() { // Arrange var applicationInformation = new ApplicationInformation(); IFilesystemAccessor filesystemAccessor = new Mock<IFilesystemAccessor>().Object; // Act var result = new PackagingFolderPathProvider(applicationInformation, filesystemAccessor); // Arrange Assert.IsNotNull(result); }
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_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 AddOrUpdate_PackageInfoParameterIsNull_ArgumentNullExceptionIsThrown() { // Arrange PackageInfo packageInfo = null; var applicationInformation = new ApplicationInformation { ConfigurationFileFolder = Environment.CurrentDirectory }; var packageInfoFilesystemPersistence = new Mock<IFilesystemPersistence<PackageInfo[]>>(); var packageConfigurationAccessor = new PackageConfigurationAccessor(applicationInformation, packageInfoFilesystemPersistence.Object); // Act packageConfigurationAccessor.AddOrUpdate(packageInfo); }
public void Constructor_AllParametersAreValid_ObjectIsInstantiated() { // Arrange var applicationInformation = new ApplicationInformation(); IPackageConfigurationAccessor packageConfigurationAccessor = new Mock<IPackageConfigurationAccessor>().Object; IFilesystemAccessor filesystemAccessor = new Mock<IFilesystemAccessor>().Object; // Act var result = new InstallationStatusProvider(applicationInformation, packageConfigurationAccessor, filesystemAccessor); // Assert Assert.IsNotNull(result); }
public void Constructor_AllParametersAreSet_ObjectIsInstantiated() { // Arrange var applicationInformation = new ApplicationInformation { ConfigurationFileFolder = Environment.CurrentDirectory }; var sourceRepositoryConfigurationFactory = new Mock<ISourceRepositoryConfigurationFactory>(); var filesystemPersistence = new Mock<IFilesystemPersistence<SourceRepositoryConfiguration[]>>(); // Act var configFileSourceRepositoryProvider = new ConfigFileSourceRepositoryProvider( applicationInformation, sourceRepositoryConfigurationFactory.Object, filesystemPersistence.Object); // Assert Assert.IsNotNull(configFileSourceRepositoryProvider); }
public void Constructor_AllParametersAreSet_ObjectIsInstantiated() { // Arrange var applicationInformation = new ApplicationInformation(); var userInterface = new Mock<IUserInterface>(); var logger = new Mock<IActionLogger>(); var commandLineArgumentInterpreter = new Mock<ICommandLineArgumentInterpreter>(); var helpCommand = new Mock<IHelpCommand>(); // Act var program = new Program(applicationInformation, userInterface.Object, logger.Object, commandLineArgumentInterpreter.Object, helpCommand.Object); // Assert Assert.IsNotNull(program); }
public void ShowHelpOverview_ApplicationName_IsWrittenToTheUserInterface() { // Arrange var commands = new List<ICommand>(); var applicationInformation = new ApplicationInformation { ApplicationName = "App Name" }; var helpProvider = new HelpProvider(applicationInformation, this.loggingUserInterface.UserInterface); // Act helpProvider.ShowHelpOverview(commands); // Assert Assert.IsTrue(this.loggingUserInterface.UserInterfaceOutput.Contains(applicationInformation.ApplicationName)); }
public HelpProvider(ApplicationInformation applicationInformation, IUserInterface userInterface) { if (applicationInformation == null) { throw new ArgumentNullException("applicationInformation"); } if (userInterface == null) { throw new ArgumentNullException("userInterface"); } this.applicationInformation = applicationInformation; this.userInterface = userInterface; }
public PackagingFolderPathProvider(ApplicationInformation applicationInformation, IFilesystemAccessor filesystemAccessor) { if (applicationInformation == null) { throw new ArgumentNullException("applicationInformation"); } if (filesystemAccessor == null) { throw new ArgumentNullException("filesystemAccessor"); } this.applicationInformation = applicationInformation; this.filesystemAccessor = filesystemAccessor; }
public void Constructor_AllParametersAreSet_ObjectIsInstantiated() { // Arrange var userInterface = new Mock<IUserInterface>(); var applicationInformation = new ApplicationInformation(); var packageRepositoryBrowser = new Mock<IPackageRepositoryBrowser>(); var filesystemAccessor = new Mock<IFilesystemAccessor>(); // Act var selfUpdateService = new SelfUpdateService( userInterface.Object, applicationInformation, packageRepositoryBrowser.Object, filesystemAccessor.Object); // Assert Assert.IsNotNull(selfUpdateService); }
public void AddOrUpdate_PackageInfoIsInvalid_ResultIsFalse() { // Arrange var packageInfo = new PackageInfo(); var applicationInformation = new ApplicationInformation { ConfigurationFileFolder = Environment.CurrentDirectory }; var packageInfoFilesystemPersistence = new Mock<IFilesystemPersistence<PackageInfo[]>>(); var packageConfigurationAccessor = new PackageConfigurationAccessor(applicationInformation, packageInfoFilesystemPersistence.Object); // Act var result = packageConfigurationAccessor.AddOrUpdate(packageInfo); // Assert Assert.AreEqual(result.Status, ServiceResultType.Failure); }
public PackageConfigurationAccessor(ApplicationInformation applicationInformation, IFilesystemPersistence<PackageInfo[]> packageInfoFilesystemPersistence) { if (applicationInformation == null) { throw new ArgumentNullException("applicationInformation"); } if (packageInfoFilesystemPersistence == null) { throw new ArgumentNullException("packageInfoFilesystemPersistence"); } this.applicationInformation = applicationInformation; this.packageInfoFilesystemPersistence = packageInfoFilesystemPersistence; this.packageConfigurationFilePath = this.GetPackageConfigurationFilePath(); }
public void BeforeEachTest() { this.sequentialTestExecutionMonitor.WaitOne(); CommandLineIntegrationTestUtilities.RemoveAllFilesAndFoldersWhichAreCreatedOnStartup(); StructureMapSetup.Setup(); this.encodingProvider = ObjectFactory.GetInstance<IEncodingProvider>(); this.applicationInformation = ObjectFactory.GetInstance<ApplicationInformation>(); this.commandProvider = ObjectFactory.GetInstance<ICommandProvider>(); this.userInterface = ObjectFactory.GetInstance<IUserInterface>(); this.logger = ObjectFactory.GetInstance<IActionLogger>(); this.commandLineArgumentInterpreter = ObjectFactory.GetInstance<ICommandLineArgumentInterpreter>(); this.helpCommand = ObjectFactory.GetInstance<IHelpCommand>(); this.program = new Program(this.applicationInformation, this.userInterface, this.logger, this.commandLineArgumentInterpreter, this.helpCommand); }
public ConfigFilePublishConfigurationAccessor(ApplicationInformation applicationInformation, IPublishConfigurationFactory publishConfigurationFactory, IFilesystemPersistence<PublishConfiguration[]> publishConfigurationPersistence) { if (applicationInformation == null) { throw new ArgumentNullException("applicationInformation"); } if (publishConfigurationPersistence == null) { throw new ArgumentNullException("publishConfigurationPersistence"); } this.applicationInformation = applicationInformation; this.publishConfigurationFactory = publishConfigurationFactory; this.publishConfigurationPersistence = publishConfigurationPersistence; this.configurationFilePath = this.GetConfigurationFilePath(); }
public void Delete_RepositoryDoesNotExist_FailureResultIsReturned() { // Arrange string repositoryName = "Some Repository"; var applicationInformation = new ApplicationInformation { ConfigurationFileFolder = Environment.CurrentDirectory }; var sourceRepositoryConfigurationFactory = new Mock<ISourceRepositoryConfigurationFactory>(); var filesystemPersistence = new Mock<IFilesystemPersistence<SourceRepositoryConfiguration[]>>(); filesystemPersistence.Setup(f => f.Load(It.IsAny<string>())).Returns(new SourceRepositoryConfiguration[] { }); var configFileSourceRepositoryProvider = new ConfigFileSourceRepositoryProvider( applicationInformation, sourceRepositoryConfigurationFactory.Object, filesystemPersistence.Object); // Act var result = configFileSourceRepositoryProvider.DeleteRepositoryConfiguration(repositoryName); // Assert Assert.AreEqual(ServiceResultType.Failure, result.Status); }
public SelfUpdateCommand(ApplicationInformation applicationInformation, ISelfUpdateService selfUpdateService, _Assembly targetAssembly) { if (applicationInformation == null) { throw new ArgumentNullException("applicationInformation"); } if (selfUpdateService == null) { throw new ArgumentNullException("selfUpdateService"); } if (targetAssembly == null) { throw new ArgumentNullException("targetAssembly"); } this.applicationInformation = applicationInformation; this.selfUpdateService = selfUpdateService; this.targetAssembly = targetAssembly; this.Attributes = new CommandAttributes { CommandName = CommandName, AlternativeCommandNames = this.alternativeCommandNames, RequiredArguments = new string[] { }, PositionalArguments = new string[] { }, Description = string.Format(Resources.SelfUpdateCommand.CommandDescriptionTextTemplate, this.applicationInformation.NameOfExecutable), Usage = string.Format("{0}", CommandName), Examples = new Dictionary<string, string> { { string.Format("{0}", CommandName), Resources.SelfUpdateCommand.CommandExampleDescription1 } }, ArgumentDescriptions = new Dictionary<string, string>() }; this.Arguments = new Dictionary<string, string>(); }