public void OnDeploymentTaskStarting_DoNothing_SoDoesNotThrow() { var deploymentRequestRepository = new Mock<IDeploymentRequestRepository>(); var auditingModule = new AuditingModule(deploymentRequestRepository.Object); var environmentInfoRepository = new Mock<IEnvironmentInfoRepository>(); var artifactsRepository = new Mock<IArtifactsRepository>(); TerminalAppProjectInfo projectInfo = new TerminalAppProjectInfo("name", "artifactsRepositoryName", "artifactsrepositoryDirName", false, "terminalAppName", "terminalAppDirName", "terminalAppExeName"); var deploymentTask = new DeployTerminalAppDeploymentTask(environmentInfoRepository.Object, artifactsRepository.Object, projectInfo, "Production", "buildId", "prod"); var deploymentContext = new DeploymentContext("requester"); Assert.DoesNotThrow(() => auditingModule.OnDeploymentTaskStarting(deploymentTask, deploymentContext)); }
public void OnDeploymentTaskStarting_DoNothing_SoDoesNotThrow() { var deploymentRequestRepository = new Mock<IDeploymentRequestRepository>(); var auditingModule = new AuditingModule(deploymentRequestRepository.Object); var projectsInfoRepository = new Mock<IProjectInfoRepository>(); var environmentInfoRepository = new Mock<IEnvironmentInfoRepository>(); var artifactsRepository = new Mock<IArtifactsRepository>(); var directoryAdapter = new Mock<IDirectoryAdapter>(); var fileAdapter = new Mock<IFileAdapter>(); var zipFileAdapter = new Mock<IZipFileAdapter>(); var deploymentTask = new DeployTerminalAppDeploymentTask(projectsInfoRepository.Object, environmentInfoRepository.Object, artifactsRepository.Object, directoryAdapter.Object, fileAdapter.Object, zipFileAdapter.Object); var deploymentContext = new DeploymentContext("requester"); DeploymentInfo deploymentInfo = DeploymentInfoGenerator.GetTerminalAppDeploymentInfo(); Assert.DoesNotThrow(() => auditingModule.OnDeploymentTaskStarting(deploymentInfo, deploymentTask, deploymentContext)); }
public void OnDeploymentTaskFinished_ExpectAddDeploymentRequest() { DeploymentInfo deploymentInfo = DeploymentInfoGenerator.GetTerminalAppDeploymentInfo(); var deploymentRequestRepository = new Mock<IDeploymentRequestRepository>(MockBehavior.Strict); var auditingModule = new AuditingModule(deploymentRequestRepository.Object); var environmentInfoRepository = new Mock<IEnvironmentInfoRepository>(); var artifactsRepository = new Mock<IArtifactsRepository>(); var projectsInfoRepository = new Mock<IProjectInfoRepository>(); var directoryAdapter = new Mock<IDirectoryAdapter>(); var fileAdapter = new Mock<IFileAdapter>(); var zipFileAdapter = new Mock<IZipFileAdapter>(); var deploymentTask = new DeployTerminalAppDeploymentTask(projectsInfoRepository.Object, environmentInfoRepository.Object, artifactsRepository.Object, directoryAdapter.Object, fileAdapter.Object, zipFileAdapter.Object); var deploymentContext = new DeploymentContext("requester"); deploymentRequestRepository .Setup( drr => drr.AddDeploymentRequest( It.Is<DeploymentRequest>( r => r.ProjectName == deploymentInfo.ProjectName && r.TargetEnvironmentName == deploymentInfo.TargetEnvironmentName))); environmentInfoRepository .Setup(x => x.FindByName(deploymentInfo.TargetEnvironmentName)) .Returns(DeploymentDataGenerator.GetEnvironmentInfo()); projectsInfoRepository .Setup(pir => pir.FindByName(deploymentInfo.ProjectName)) .Returns(DeploymentDataGenerator.GetTerminalAppProjectInfo()); deploymentTask.Initialize(deploymentInfo); deploymentTask.Prepare(); Assert.DoesNotThrow(() => auditingModule.OnDeploymentTaskFinished(deploymentInfo, deploymentTask, deploymentContext)); }
public void OnDeploymentTaskFinished_ExpectAddDeploymnetRequest() { string projectName = "projectName"; string targetEnvironmentName = "targetEnvironmentName"; var deploymentRequestRepository = new Mock<IDeploymentRequestRepository>(MockBehavior.Strict); var auditingModule = new AuditingModule(deploymentRequestRepository.Object); var environmentInfoRepository = new Mock<IEnvironmentInfoRepository>(); var artifactsRepository = new Mock<IArtifactsRepository>(); TerminalAppProjectInfo projectInfo = new TerminalAppProjectInfo(projectName, "artifactsRepositoryName", "artifactsrepositoryDirName", false, "terminalAppName", "terminalAppDirName", "terminalAppExeName"); var deploymentTask = new DeployTerminalAppDeploymentTask(environmentInfoRepository.Object, artifactsRepository.Object, projectInfo, "Production", "buildId", targetEnvironmentName); var deploymentContext = new DeploymentContext("requester"); deploymentRequestRepository .Setup( drr => drr.AddDeploymentRequest( It.Is<DeploymentRequest>( r => r.ProjectName == projectName && r.TargetEnvironmentName == targetEnvironmentName))); Assert.DoesNotThrow(() => auditingModule.OnDeploymentTaskFinished(deploymentTask, deploymentContext)); }
public static void Bootstrap() { var container = ObjectFactory.Container; container.Register( Component.For<IApplicationConfiguration>() .UsingFactoryMethod(() => new XmlApplicationConfiguration(_ApplicationConfigPath)) .LifeStyle.Singleton, Component.For<IProjectInfoRepository>() .UsingFactoryMethod(() => new XmlProjectInfoRepository(_ProjectInfoPath)) .LifeStyle.Singleton, Component.For<IEnvironmentInfoRepository>() .UsingFactoryMethod(() => new XmlEnvironmentInfoRepository(_EnvironmentInfoPath)) .LifeStyle.Singleton); container.Register( Component.For<IDirectoryAdapter>() .ImplementedBy<DirectoryAdapter>() .LifeStyle.Is(LifestyleType.Transient)); container.Register( Component.For<ITeamCityClient>() .UsingFactoryMethod( () => { var appConfig = container.Resolve<IApplicationConfiguration>(); return new TeamCityClient( appConfig.TeamCityHostName, appConfig.TeamCityPort, appConfig.TeamCityUserName, appConfig.TeamCityPassword); }) .LifeStyle.Transient); container.Register( Component.For<IArtifactsRepository>() .UsingFactoryMethod(() => new TeamCityArtifactsRepository(container.Resolve<ITeamCityClient>())) .LifeStyle.Transient); container.Register( Component.For<IDeploymentRequestRepository>() .UsingFactoryMethod(() => new NHibernateDeploymentRequestRepository(SessionFactory)) .LifeStyle.Transient); container.Register( Component.For<INtServiceManager>() .UsingFactoryMethod( () => { var appConfig = container.Resolve<IApplicationConfiguration>(); return new ScExeBasedNtServiceManager( appConfig.ScExePath, _NtServiceManagerOperationsTimeout); }) .LifeStyle.Transient); container.Register( Component.For<ITaskScheduler>() .ImplementedBy<TaskScheduler>() .LifeStyle.Transient); // TODO IMM HI: config? container.Register( Component.For<IMsDeploy>() .UsingFactoryMethod(() => new MsDeploy(Path.Combine(_BaseDirPath, "msdeploy.exe"))) .LifeStyle.Transient); // TODO IMM HI: config? container.Register( Component.For<IIisManager>() .UsingFactoryMethod(() => new MsDeployBasedIisManager(container.Resolve<IMsDeploy>())) .LifeStyle.Transient); // TODO IMM HI: config? container.Register( Component.For<IDeploymentPipeline>() .UsingFactoryMethod( () => { var deploymentRequestRepository = container.Resolve<IDeploymentRequestRepository>(); var auditingModule = new AuditingModule(deploymentRequestRepository); var enforceTargetEnvironmentConstraintsModule = new EnforceTargetEnvironmentConstraintsModule(); var deploymentPipeline = new DeploymentPipeline(); deploymentPipeline.AddModule(auditingModule); deploymentPipeline.AddModule(enforceTargetEnvironmentConstraintsModule); return deploymentPipeline; }) .LifeStyle.Transient); container.Register( Component.For<IDbVersionProvider>() .UsingFactoryMethod( () => { IEnumerable<DbVersionTableInfo> versionTableInfos = new List<DbVersionTableInfo> { new DbVersionTableInfo { TableName = "VERSION", ColumnName = "dbVersion" }, new DbVersionTableInfo { TableName = "VERSIONHISTORY", ColumnName = "DBLabel" } }; return new DbVersionProvider(versionTableInfos); }) .LifeStyle.Transient); container.Register( Component.For<IProjectMetadataExplorer>() .ImplementedBy<ProjectMetadataExplorer>() .LifeStyle.Is(LifestyleType.Transient)); container.Register( Component.For<IDirPathParamsResolver>() .UsingFactoryMethod( () => { var appConfig = container.Resolve<IApplicationConfiguration>(); return new DirPathParamsResolver(appConfig.ManualDeploymentPackageCurrentDateFormat); }) .LifeStyle.Is(LifestyleType.Transient)); }
public static void Bootstrap(bool mockTeamCity = false) { var container = ObjectFactory.Container; container.Register( Component.For<IApplicationConfigurationRepository>() .UsingFactoryMethod(() => new XmlApplicationConfigurationRepository(_ApplicationConfigPath)) .LifeStyle.Transient, Component.For<IApplicationConfiguration>() .UsingFactoryMethod((kernel) => kernel.Resolve<IApplicationConfigurationRepository>().LoadConfiguration()) .LifeStyle.Singleton, Component.For<IProjectInfoRepository>() .UsingFactoryMethod(() => new XmlProjectInfoRepository(_ProjectInfosFilePath)) .LifeStyle.Singleton, Component.For<IEnvironmentInfoRepository>() .UsingFactoryMethod(() => new XmlEnvironmentInfoRepository(_EnvironmentInfosDirPath)) .LifeStyle.Singleton, Component.For<IEnvironmentDeployInfoRepository>() .UsingFactoryMethod(() => new JsonEnvironmentDeployInfoRepository(_EnvironmentDeployInfosDirPath)) .LifeStyle.Singleton); container.Register( Component.For<IDirectoryAdapter>() .ImplementedBy<DirectoryAdapter>() .LifeStyle.Is(LifestyleType.Transient)); container.Register( Component.For<ITeamCityClient>() .UsingFactoryMethod( () => { var appConfig = container.Resolve<IApplicationConfiguration>(); var client = new TeamCityClient( appConfig.TeamCityHostName, appConfig.TeamCityPort, appConfig.TeamCityUserName, appConfig.TeamCityPassword); container.Release(appConfig); return client; }) .LifeStyle.Transient); container.Register( Component.For<ITeamCityRestClient>() .UsingFactoryMethod( () => { var appConfig = container.Resolve<IApplicationConfiguration>(); ITeamCityRestClient restClient; if (mockTeamCity) { restClient = new MockedTeamCityRestClient(); } else { restClient = new TeamCityRestClient( new Uri(string.Format("http://{0}:{1}", appConfig.TeamCityHostName, appConfig.TeamCityPort)), appConfig.TeamCityUserName, appConfig.TeamCityPassword); } container.Release(appConfig); return restClient; }) .LifeStyle.Transient); container.Register( Component.For<IArtifactsRepository>().ImplementedBy<TeamCityArtifactsRepository>() .LifeStyle.Transient); container.Register( Component.For<IDeploymentRequestRepository>() .UsingFactoryMethod(() => new NHibernateDeploymentRequestRepository(SessionFactory)) .LifeStyle.Transient); container.Register( Component.For<INtServiceManager>() .UsingFactoryMethod( () => { var appConfig = container.Resolve<IApplicationConfiguration>(); return new ScExeBasedNtServiceManager( appConfig.ScExePath, _NtServiceManagerOperationsTimeout); }) .LifeStyle.Transient); container.Register( Component.For<ITaskScheduler>() .ImplementedBy<TaskScheduler>() .LifeStyle.Transient); // TODO IMM HI: config? container.Register( Component.For<IMsDeploy>() .UsingFactoryMethod(() => new MsDeploy(Path.Combine(_BaseDirPath, "msdeploy.exe"))) .LifeStyle.Transient); // TODO IMM HI: config? container.Register( Component.For<IIisManager>() .UsingFactoryMethod(() => new MsDeployBasedIisManager(container.Resolve<IMsDeploy>())) .LifeStyle.Transient); // TODO IMM HI: config? container.Register( Component.For<IDeploymentPipeline>() .UsingFactoryMethod( () => { var deploymentRequestRepository = container.Resolve<IDeploymentRequestRepository>(); var applicationConfiguration = container.Resolve<IApplicationConfiguration>(); var auditingModule = new AuditingModule(deploymentRequestRepository); var enforceTargetEnvironmentConstraintsModule = new EnforceTargetEnvironmentConstraintsModule(); var deploymentPipeline = new DeploymentPipeline(applicationConfiguration, ObjectFactory.Instance); deploymentPipeline.AddModule(auditingModule); deploymentPipeline.AddModule(enforceTargetEnvironmentConstraintsModule); return deploymentPipeline; }) .LifeStyle.Transient); container.Register( Component.For<IEnvDeploymentPipeline>() .ImplementedBy<EnvDeploymentPipeline>() .LifeStyle.Transient); container.Register( Component.For<IDbManagerFactory>() .ImplementedBy<MsSqlDbManagerFactory>() .LifeStyle.Transient); container.Register( Component.For<IMsSqlDatabasePublisher>() .UsingFactoryMethod( kernel => { var applicationConfiguration = kernel.Resolve<IApplicationConfiguration>(); var cmdExecutor = kernel.Resolve<ICmdExecutor>(); return new MsSqlDatabasePublisher(cmdExecutor, applicationConfiguration.SqlPackageDirPath); }) .LifeStyle.Transient); container.Register( Component.For<ICmdExecutor>() .ImplementedBy<CmdExecutor>() .LifeStyle.Transient); container.Register( Component.For<IDbVersionProvider>() .UsingFactoryMethod( () => { // order is important - from more specific to less IEnumerable<DbVersionTableInfo> versionTableInfos = new List<DbVersionTableInfo> { new DbVersionTableInfo { TableName = "VERSION", VersionColumnName = "dbVersion", MigrationColumnName = "migrated" }, new DbVersionTableInfo { TableName = "VERSION", VersionColumnName = "dbVersion" }, new DbVersionTableInfo { TableName = "VERSIONHISTORY", VersionColumnName = "DBLabel" } }; return new DbVersionProvider(versionTableInfos); }) .LifeStyle.Transient); container.Register( Component.For<IProjectMetadataExplorer>() .ImplementedBy<ProjectMetadataExplorer>() .LifeStyle.Is(LifestyleType.Transient)); container.Register( Component.For<IDirPathParamsResolver>() .UsingFactoryMethod( () => { var appConfig = container.Resolve<IApplicationConfiguration>(); return new DirPathParamsResolver(appConfig.ManualDeploymentPackageCurrentDateFormat); }) .LifeStyle.Is(LifestyleType.Transient)); container.Register( Component.For<IDbScriptRunnerFactory>() .ImplementedBy<MsSqlDbScriptRunnerFactory>() .LifeStyle.Is(LifestyleType.Transient)); container.Register( Component.For<IUserNameNormalizer>() .ImplementedBy<UserNameNormalizer>() .LifeStyle.Transient); }