public void MissingBranchName_ThrowsError() { var repository = new Mock<IProjectRepository>(); string projectId = Guid.NewGuid().ToString(); string branchName = string.Empty; IProjectManager sut = new ProjectManager(repository.Object, new Mock<IDeployTaskFactory>().Object); Assert.Throws<ArgumentNullException>(delegate { sut.CreateBranch(projectId, branchName); }); repository.Verify(i => i.CreateBranch(It.IsAny<string>(), It.IsAny<string>()), Times.Never()); }
public void CanCreateProjectBranch() { var repository = new Mock<IProjectRepository>(); string projectId = Guid.NewGuid().ToString(); var branch = new DeployProjectBranch { Id = Guid.NewGuid().ToString(), ProjectId = Guid.NewGuid().ToString(), BranchName = Guid.NewGuid().ToString() }; repository.Setup(i=>i.CreateBranch(branch.ProjectId, branch.BranchName)).Returns(branch); IProjectManager sut = new ProjectManager(repository.Object, new Mock<IDeployTaskFactory>().Object); var result = sut.CreateBranch(branch.ProjectId, branch.BranchName); Assert.AreEqual(branch, result); repository.Verify(i=>i.CreateBranch(branch.ProjectId, branch.BranchName), Times.Once()); }