コード例 #1
0
        public void SetUp()
        {
            _projectInfoRepositoryFake     = new Mock <IProjectInfoRepository>(MockBehavior.Loose);
            _environmentInfoRepositoryFake = new Mock <IEnvironmentInfoRepository>(MockBehavior.Loose);
            _artifactsRepositoryFake       = new Mock <IArtifactsRepository>(MockBehavior.Loose);
            _dbScriptRunnerFactoryFake     = new Mock <IDbScriptRunnerFactory>(MockBehavior.Loose);
            _dbVersionProviderFake         = new Mock <IDbVersionProvider>(MockBehavior.Loose);
            _fileAdapterFake             = new Mock <IFileAdapter>();
            _zipFileAdapterFake          = new Mock <IZipFileAdapter>();
            _scriptsToRunWebSelectorFake = new Mock <IScriptsToRunSelector>();
            _databasePublisherFake       = new Mock <IMsSqlDatabasePublisher>();
            _dbManagerFake          = new Mock <IDbManagerFactory>();
            _userNameNormalizerMock = new Mock <IUserNameNormalizer>();
            _directoryAdapterFake   = new Mock <IDirectoryAdapter>();

            _projectInfoRepositoryFake
            .Setup(x => x.FindByName(It.IsAny <string>()))
            .Returns(ProjectInfoGenerator.GetDbProjectInfo());

            _environmentInfoRepositoryFake
            .Setup(x => x.FindByName(It.IsAny <string>()))
            .Returns(DeploymentDataGenerator.GetEnvironmentInfo);

            _dbScriptRunnerFactoryFake
            .Setup(x => x.CreateDbScriptRunner(It.IsAny <bool>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .Returns(new Mock <IDbScriptRunner>(MockBehavior.Loose).Object);

            _deploymentTask =
                new DeployDbProjectDeploymentTask(
                    _projectInfoRepositoryFake.Object,
                    _environmentInfoRepositoryFake.Object,
                    _artifactsRepositoryFake.Object,
                    _dbScriptRunnerFactoryFake.Object,
                    _dbVersionProviderFake.Object,
                    _fileAdapterFake.Object,
                    _zipFileAdapterFake.Object,
                    _scriptsToRunWebSelectorFake.Object,
                    _databasePublisherFake.Object,
                    _dbManagerFake.Object,
                    _userNameNormalizerMock.Object,
                    _directoryAdapterFake.Object);

            _deploymentTask.Initialize(DeploymentInfoGenerator.GetDbDeploymentInfo());

            _dbVersionProviderFake.Setup(x => x.CheckIfDatabaseExists(It.IsAny <string>(), It.IsAny <string>())).Returns(true);

            _databasePublisherFake.Setup(
                x =>
                x.PublishFromDacpac(
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <string>(),
                    It.IsAny <Dictionary <string, string> >()));
        }
コード例 #2
0
        private IEnumerable <ProjectDeploymentData> CreateProjectEnvironmentDeployments(Guid uniqueClientId, EnvironmentDeployInfo environmentDeployInfo, IEnumerable <ProjectToDeploy> projects)
        {
            var projectDeployments         = new List <ProjectDeploymentData>();
            var priorityProjectDeplyoments = new List <ProjectDeploymentData>();

            EnvironmentInfo environmentInfo = _environmentInfoRepository.FindByName(environmentDeployInfo.TargetEnvironment);

            if (environmentInfo == null)
            {
                throw new FaultException <EnvironmentNotFoundFault>(new EnvironmentNotFoundFault {
                    EnvironmentName = environmentDeployInfo.TargetEnvironment
                });
            }

            foreach (var projectToDeploy in projects)
            {
                try
                {
                    ProjectInfo projectInfo = _projectInfoRepository.FindByName(projectToDeploy.ProjectName);

                    if (projectInfo == null)
                    {
                        throw new DeploymentTaskException(string.Format("Not found configuration for project: {0}", projectToDeploy.ProjectName));
                    }

                    ProjectConfigurationBuild lastSuccessfulBuild = GetLatestSuccessfulBuild(projectToDeploy.ProjectName, environmentDeployInfo.BuildConfigurationName);

                    if (lastSuccessfulBuild == null)
                    {
                        throw new DeploymentTaskException(string.Format("Successful build not found for project: {0} and configuration: {1}", projectToDeploy, environmentDeployInfo.BuildConfigurationName));
                    }

                    InputParams inputParams = BuildInputParams(projectInfo, environmentInfo);

                    var deploymentInfo = new Core.Domain.DeploymentInfo(projectToDeploy.DeploymentId, false, projectToDeploy.ProjectName, environmentDeployInfo.BuildConfigurationName, lastSuccessfulBuild.Id, environmentDeployInfo.TargetEnvironment, inputParams);

                    DeploymentTask deploymentTask;

                    // TODO LK: could replace below code with factory
                    if (projectInfo.Type == ProjectType.Db)
                    {
                        DeploymentTask dropDbProjectDeploymentTask = new DropDbProjectDeploymentTask(
                            ObjectFactory.Instance.CreateProjectInfoRepository(),
                            ObjectFactory.Instance.CreateEnvironmentInfoRepository(),
                            ObjectFactory.Instance.CreateDbManagerFactory());

                        priorityProjectDeplyoments.Add(new ProjectDeploymentData(deploymentInfo, projectInfo, dropDbProjectDeploymentTask));

                        deploymentTask =
                            new DeployDbProjectDeploymentTask(
                                ObjectFactory.Instance.CreateProjectInfoRepository(),
                                ObjectFactory.Instance.CreateEnvironmentInfoRepository(),
                                ObjectFactory.Instance.CreateArtifactsRepository(),
                                ObjectFactory.Instance.CreateDbScriptRunnerFactory(),
                                ObjectFactory.Instance.CreateDbVersionProvider(),
                                ObjectFactory.Instance.CreateFileAdapter(),
                                ObjectFactory.Instance.CreateZipFileAdapter(),
                                ObjectFactory.Instance.CreateScriptsToRunWebSelectorForEnvironmentDeploy(),
                                ObjectFactory.Instance.CreateMsSqlDatabasePublisher(),
                                ObjectFactory.Instance.CreateDbManagerFactory(),
                                ObjectFactory.Instance.CreateUserNameNormalizer(),
                                ObjectFactory.Instance.CreateDirectoryAdapter());
                    }
                    else if (projectInfo.Type == ProjectType.NtService)
                    {
                        deploymentTask = new DeployNtServiceDeploymentTask(
                            ObjectFactory.Instance.CreateProjectInfoRepository(),
                            ObjectFactory.Instance.CreateEnvironmentInfoRepository(),
                            ObjectFactory.Instance.CreateArtifactsRepository(),
                            ObjectFactory.Instance.CreateNtServiceManager(),
                            ObjectFactory.Instance.CreatePasswordCollector(),
                            ObjectFactory.Instance.CreateFailoverClusterManager(),
                            ObjectFactory.Instance.CreateDirectoryAdapter(),
                            ObjectFactory.Instance.CreateFileAdapter(),
                            ObjectFactory.Instance.CreateZipFileAdapter())
                        {
                            UseLocalSystemUser = true
                        };
                    }
                    else
                    {
                        deploymentTask = projectInfo.CreateDeploymentTask(ObjectFactory.Instance);
                    }

                    projectDeployments.Add(new ProjectDeploymentData(deploymentInfo, projectInfo, deploymentTask));
                }
                catch (Exception e)
                {
                    LogMessage(uniqueClientId, DiagnosticMessageType.Error, e.Message);
                }
            }

            priorityProjectDeplyoments.AddRange(projectDeployments);

            return(priorityProjectDeplyoments);
        }
コード例 #3
0
ファイル: AgentService.cs プロジェクト: spawluk/UberDeployer
        private IEnumerable<ProjectDeploymentData> CreateProjectEnvironmentDeployments(Guid uniqueClientId, EnvironmentDeployInfo environmentDeployInfo, IEnumerable<ProjectToDeploy> projects)
        {
            var projectDeployments = new List<ProjectDeploymentData>();
              var priorityProjectDeplyoments = new List<ProjectDeploymentData>();

              EnvironmentInfo environmentInfo = _environmentInfoRepository.FindByName(environmentDeployInfo.TargetEnvironment);

              if (environmentInfo == null)
              {
            throw new FaultException<EnvironmentNotFoundFault>(new EnvironmentNotFoundFault { EnvironmentName = environmentDeployInfo.TargetEnvironment });
              }

              foreach (var projectToDeploy in projects)
              {
            try
            {
              ProjectInfo projectInfo = _projectInfoRepository.FindByName(projectToDeploy.ProjectName);

              if (projectInfo == null)
              {
            throw new DeploymentTaskException(string.Format("Not found configuration for project: {0}", projectToDeploy.ProjectName));
              }

              ProjectConfigurationBuild lastSuccessfulBuild = GetLatestSuccessfulBuild(projectToDeploy.ProjectName, environmentDeployInfo.BuildConfigurationName);

              if (lastSuccessfulBuild == null)
              {
            throw new DeploymentTaskException(string.Format("Successful build not found for project: {0} and configuration: {1}", projectToDeploy, environmentDeployInfo.BuildConfigurationName));
              }

              InputParams inputParams = BuildInputParams(projectInfo, environmentInfo);

              var deploymentInfo = new Core.Domain.DeploymentInfo(projectToDeploy.DeploymentId, false, projectToDeploy.ProjectName, environmentDeployInfo.BuildConfigurationName, lastSuccessfulBuild.Id, environmentDeployInfo.TargetEnvironment, inputParams);

              DeploymentTask deploymentTask;

              // TODO LK: could replace below code with factory
              if (projectInfo.Type == ProjectType.Db)
              {
            DeploymentTask dropDbProjectDeploymentTask = new DropDbProjectDeploymentTask(
              ObjectFactory.Instance.CreateProjectInfoRepository(),
              ObjectFactory.Instance.CreateEnvironmentInfoRepository(),
              ObjectFactory.Instance.CreateDbManagerFactory());

            priorityProjectDeplyoments.Add(new ProjectDeploymentData(deploymentInfo, projectInfo, dropDbProjectDeploymentTask));

            deploymentTask =
              new DeployDbProjectDeploymentTask(
                ObjectFactory.Instance.CreateProjectInfoRepository(),
                ObjectFactory.Instance.CreateEnvironmentInfoRepository(),
                ObjectFactory.Instance.CreateArtifactsRepository(),
                ObjectFactory.Instance.CreateDbScriptRunnerFactory(),
                ObjectFactory.Instance.CreateDbVersionProvider(),
                ObjectFactory.Instance.CreateFileAdapter(),
                ObjectFactory.Instance.CreateZipFileAdapter(),
                ObjectFactory.Instance.CreateScriptsToRunWebSelectorForEnvironmentDeploy(),
                ObjectFactory.Instance.CreateMsSqlDatabasePublisher(),
                ObjectFactory.Instance.CreateDbManagerFactory(),
                ObjectFactory.Instance.CreateUserNameNormalizer(),
                ObjectFactory.Instance.CreateDirectoryAdapter());
              }
              else if (projectInfo.Type == ProjectType.NtService)
              {
            deploymentTask = new DeployNtServiceDeploymentTask(
              ObjectFactory.Instance.CreateProjectInfoRepository(),
              ObjectFactory.Instance.CreateEnvironmentInfoRepository(),
              ObjectFactory.Instance.CreateArtifactsRepository(),
              ObjectFactory.Instance.CreateNtServiceManager(),
              ObjectFactory.Instance.CreatePasswordCollector(),
              ObjectFactory.Instance.CreateFailoverClusterManager(),
              ObjectFactory.Instance.CreateDirectoryAdapter(),
              ObjectFactory.Instance.CreateFileAdapter(),
              ObjectFactory.Instance.CreateZipFileAdapter())
            {
              UseLocalSystemUser = true
            };
              }
              else
              {
            deploymentTask = projectInfo.CreateDeploymentTask(ObjectFactory.Instance);
              }

              projectDeployments.Add(new ProjectDeploymentData(deploymentInfo, projectInfo, deploymentTask));
            }
            catch (Exception e)
            {
              LogMessage(uniqueClientId, DiagnosticMessageType.Error, e.Message);
            }
              }

              priorityProjectDeplyoments.AddRange(projectDeployments);

              return priorityProjectDeplyoments;
        }
コード例 #4
0
        public void SetUp()
        {
            _projectInfoRepositoryFake = new Mock<IProjectInfoRepository>(MockBehavior.Loose);
              _environmentInfoRepositoryFake = new Mock<IEnvironmentInfoRepository>(MockBehavior.Loose);
              _artifactsRepositoryFake = new Mock<IArtifactsRepository>(MockBehavior.Loose);
              _dbScriptRunnerFactoryFake = new Mock<IDbScriptRunnerFactory>(MockBehavior.Loose);
              _dbVersionProviderFake = new Mock<IDbVersionProvider>(MockBehavior.Loose);
              _fileAdapterFake = new Mock<IFileAdapter>();
              _zipFileAdapterFake = new Mock<IZipFileAdapter>();
              _scriptsToRunWebSelectorFake = new Mock<IScriptsToRunSelector>();
              _databasePublisherFake = new Mock<IMsSqlDatabasePublisher>();
              _dbManagerFake = new Mock<IDbManagerFactory>();
              _userNameNormalizerMock = new Mock<IUserNameNormalizer>();
              _directoryAdapterFake = new Mock<IDirectoryAdapter>();

              _projectInfoRepositoryFake
            .Setup(x => x.FindByName(It.IsAny<string>()))
            .Returns(ProjectInfoGenerator.GetDbProjectInfo());

              _environmentInfoRepositoryFake
            .Setup(x => x.FindByName(It.IsAny<string>()))
            .Returns(DeploymentDataGenerator.GetEnvironmentInfo);

              _dbScriptRunnerFactoryFake
            .Setup(x => x.CreateDbScriptRunner(It.IsAny<bool>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>()))
            .Returns(new Mock<IDbScriptRunner>(MockBehavior.Loose).Object);

              _deploymentTask =
            new DeployDbProjectDeploymentTask(
              _projectInfoRepositoryFake.Object,
              _environmentInfoRepositoryFake.Object,
              _artifactsRepositoryFake.Object,
              _dbScriptRunnerFactoryFake.Object,
              _dbVersionProviderFake.Object,
              _fileAdapterFake.Object,
              _zipFileAdapterFake.Object,
              _scriptsToRunWebSelectorFake.Object,
              _databasePublisherFake.Object,
              _dbManagerFake.Object,
              _userNameNormalizerMock.Object,
              _directoryAdapterFake.Object);

              _deploymentTask.Initialize(DeploymentInfoGenerator.GetDbDeploymentInfo());

              _dbVersionProviderFake.Setup(x => x.CheckIfDatabaseExists(It.IsAny<string>(), It.IsAny<string>())).Returns(true);

              _databasePublisherFake.Setup(
            x =>
            x.PublishFromDacpac(
              It.IsAny<string>(),
              It.IsAny<string>(),
              It.IsAny<string>(),
              It.IsAny<Dictionary<string, string>>()));
        }