public void MissingTaskOptions_ThrowsError() { string projectId = Guid.NewGuid().ToString(); string componentId = Guid.NewGuid().ToString(); string deploymentStepId = Guid.NewGuid().ToString(); string stepName = Guid.NewGuid().ToString(); string taskTypeName = typeof(TestTaskType).ToString(); string taskOptionsJson = null; var projectRepository = new Mock<IProjectRepository>(); IProjectManager sut = new ProjectManager(projectRepository.Object, new Mock<IDeployTaskFactory>().Object); Assert.Throws<ArgumentNullException>(() => sut.UpdateComponentDeploymentStep(projectId, componentId, deploymentStepId, stepName, taskTypeName, taskOptionsJson)); projectRepository.Verify(i => i.UpdateComponentDeploymentStep(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int?>()), Times.Never()); }
public void CanUpdateDeploymentStep() { string projectId = Guid.NewGuid().ToString(); string componentId = Guid.NewGuid().ToString(); string deploymentStepId = Guid.NewGuid().ToString(); string stepName = Guid.NewGuid().ToString(); string taskTypeName = typeof(TestTaskType).ToString(); string taskOptionsJson = Guid.NewGuid().ToString(); var projectRepository = new Mock<IProjectRepository>(); var project = new DeployProject { Id = projectId, ComponentList = new List<DeployComponent>(), UsesSharedComponentConfiguration = false }; projectRepository.Setup(i=>i.GetProject(projectId)).Returns(project); projectRepository.Setup(i => i.UpdateComponentDeploymentStep(deploymentStepId, project.Id, componentId, stepName, taskTypeName, taskOptionsJson, null, null)) .Returns(new DeployStep { Id = deploymentStepId, StepName = stepName, TaskTypeName = taskTypeName, TaskOptionsJson = Guid.NewGuid().ToString(), ParentId = componentId, ProjectId = projectId, SharedDeploymentStepId = Guid.NewGuid().ToString(), }); IProjectManager sut = new ProjectManager(projectRepository.Object, new Mock<IDeployTaskFactory>().Object); var result = sut.UpdateComponentDeploymentStep(deploymentStepId, projectId, componentId, stepName, taskTypeName, taskOptionsJson); Assert.IsNotNull(result); Assert.AreEqual(stepName, result.StepName); projectRepository.Verify(i => i.UpdateComponentDeploymentStep(deploymentStepId, project.Id, componentId, stepName, taskTypeName, taskOptionsJson,null, null), Times.Once()); }