private DeployStep CreateTestStep(IProjectRepository sut, DeployConfiguration configuration = null)
 {
     if (configuration == null)
     {
         configuration = this.CreateTestConfiguration(sut);
     }
     return sut.CreateConfigurationDeploymentStep(configuration.ProjectId, configuration.Id, this.Fixture.Create<string>("StepName"), this.Fixture.Create<string>("TaskTypeName"), this.Fixture.Create<string>("TaskOptionsJson"));
 }
		public object Post(DeployConfiguration configuration)
		{
			if (string.IsNullOrEmpty(configuration.Id))
			{
				return _projectManager.CreateConfiguration(configuration.ProjectId, configuration.ConfigurationName, configuration.IsolationType);
			}
			else
			{
				return _projectManager.UpdateConfiguration(configuration.Id, configuration.ProjectId, configuration.ConfigurationName, configuration.IsolationType);
			}
		}
 private void AssertConfiguration(DeployConfiguration expected, DeployConfiguration actual)
 {
     Assert.AreEqual(expected.Id, actual.Id);
     Assert.AreEqual(expected.ProjectId, actual.ProjectId);
     Assert.AreEqual(expected.ConfigurationName, actual.ConfigurationName);
     Assert.AreEqual(expected.IsolationType, actual.IsolationType);
     AssertDateEqual(expected.CreatedDateTimeUtc, actual.CreatedDateTimeUtc);
     Assert.AreEqual(expected.CreatedByUserName, actual.CreatedByUserName);
     AssertDateEqual(expected.UpdatedDateTimeUtc, actual.UpdatedDateTimeUtc);
     Assert.AreEqual(expected.UpdatedByUserName, actual.UpdatedByUserName);
 }
		public object Get(DeployConfiguration request)
		{
			if(request == null || 
				(string.IsNullOrEmpty(request.Id) && string.IsNullOrEmpty(request.ProjectId)))
			{
				throw new ArgumentNullException();
			}
			if (!string.IsNullOrEmpty(request.Id))
			{
				return _projectManager.GetConfiguration(request.Id, request.ProjectId);
			}
			else 
			{
				return _projectManager.GetConfigurationList(request.ProjectId);
			}

		}
        private void AssertCreatedStep(DeployStep result, DeployConfiguration component, string stepName, string taskTypeName, string taskOptionsJson, IProjectRepository sut)
        {
            Assert.IsNotNull(result);
            Assert.IsNotNullOrEmpty(result.Id);
            Assert.AreEqual(component.ProjectId, result.ProjectId);
            Assert.AreEqual(component.Id, result.ParentId);
            Assert.AreEqual(EnumDeployStepParentType.Configuration, result.ParentType);
            Assert.AreEqual(stepName, result.StepName);
            Assert.AreEqual(taskTypeName, result.TaskTypeName);
            Assert.AreEqual(taskOptionsJson, result.TaskOptionsJson);
            Assert.IsNull(result.SharedDeploymentStepId);
            Assert.AreEqual(this.UserName, result.CreatedByUserName);
            AssertIsRecent(result.CreatedDateTimeUtc);
            Assert.AreEqual(this.UserName, result.UpdatedByUserName);
            AssertIsRecent(result.UpdatedDateTimeUtc);

            var dbItem = sut.GetConfigurationDeploymentStep(result.Id, result.ProjectId);
            AssertStep(result, dbItem);
        }
 private void LoadConfigurationChildren(DeployConfiguration item)
 {
     item.DeploymentStepList = this.GetConfigurationDeploymentStepList(item.Id, item.ProjectId);
 }
        public DeployConfiguration CreateConfiguration(string projectId, string configurationName, EnumDeploymentIsolationType isolationType)
        {
            if(string.IsNullOrEmpty(projectId))
            {
                throw new ArgumentNullException("Missing project name");
            }
            if(string.IsNullOrEmpty(configurationName))
            {
                throw new ArgumentNullException("Missing configuration name");
            }
            VerifyProjectExists(projectId);
            var configuration = new DeployConfiguration
            {
                Id = Guid.NewGuid().ToString(),
                ProjectId = projectId,
                ConfigurationName = configurationName,
                IsolationType = isolationType,
                CreatedByUserName = _userIdentity.UserName,
                CreatedDateTimeUtc = DateTime.UtcNow,
                UpdatedByUserName = _userIdentity.UserName,
                UpdatedDateTimeUtc = DateTime.UtcNow
            };

            using(var db = _sqlConnectionInfo.GetDB())
            {
                var sql = PetaPoco.Sql.Builder
                            .Append("INSERT INTO DeployConfiguration (ID, DeployProjectID, ConfigurationName, EnumDeploymentIsolationTypeID, CreatedByUserName, CreatedDateTimeUtc, UpdatedByUserName, UpdatedDateTimeUtc)")
                            .Append("VALUES (@Id, @ProjectId, @ConfigurationName, @IsolationType, @CreatedByUserName, @CreatedDateTimeUtc, @UpdatedByUserName, @UpdatedDateTimeUtc)", configuration);
                db.Execute(sql);
            }
            return configuration;
        }
		public void Delete(DeployConfiguration configuration)
		{
			_projectManager.DeleteConfiguration(configuration.Id, configuration.ProjectId);
		}
 private DeployEnvironmentConfiguration GetCreateTestDeployEnvironmentConfiguration(DeployConfiguration configuration)
 {
     return new DeployEnvironmentConfiguration
     {
         ConfigurationValueList = this.CreateTestConfigurationValueList(),
         DeployCredentialsId = null,
         ParentId = configuration.Id,
         MachineList = CreateTestMachineList(5)
     };
 }