public void OnDeploymentTaskStarting_WhenEnvironmentIsProductionAndConfigurationIsNot_ThrowsInvalidOperationException() { var enforceTargetEnvironmentConstraintsModule = new EnforceTargetEnvironmentConstraintsModule(); 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, "trunk", "buildId", "prod"); var deploymentContext = new DeploymentContext("requester"); Assert.Throws<InvalidOperationException>(() => enforceTargetEnvironmentConstraintsModule.OnDeploymentTaskStarting(deploymentTask, deploymentContext)); }
public void OnDeploymentTaskFinished_DoNothing_SoDoesNotThrows() { var enforceTargetEnvironmentConstraintsModule = new EnforceTargetEnvironmentConstraintsModule(); 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(() => enforceTargetEnvironmentConstraintsModule.OnDeploymentTaskFinished(deploymentTask, deploymentContext)); }
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 void SetUp() { _environmentInfoRepositoryFake = new Mock<IEnvironmentInfoRepository>(); _artifactsRepositoryFake = new Mock<IArtifactsRepository>(); _projectsInfoRepositoryFake = new Mock<IProjectInfoRepository>(); _directoryAdapterFake = new Mock<IDirectoryAdapter>(MockBehavior.Loose); _fileAdapterFake = new Mock<IFileAdapter>(MockBehavior.Loose); _zipFileAdapterFake = new Mock<IZipFileAdapter>(MockBehavior.Loose); _deploymentContext = new DeploymentContext("requester"); _deploymentTask = new DeployTerminalAppDeploymentTask( _projectsInfoRepositoryFake.Object, _environmentInfoRepositoryFake.Object, _artifactsRepositoryFake.Object, _directoryAdapterFake.Object, _fileAdapterFake.Object, _zipFileAdapterFake.Object); _enforceTargetEnvironmentConstraintsModule = new EnforceTargetEnvironmentConstraintsModule(); }