Deploy() private method

private Deploy ( string id = null ) : Task
id string
return Task
        public async Task RedeployReturns404IfRepoDoesNotExist()
        {
            // Arrange
            var repoFactory = new Mock<IRepositoryFactory>();
            repoFactory.Setup(r => r.GetRepository()).Returns((IRepository)null);
            var opLock = new Mock<IOperationLock>();
            opLock.Setup(f => f.Lock()).Returns(true);
            var controller = new DeploymentController(Mock.Of<ITracer>(), Mock.Of<IEnvironment>(), Mock.Of<IAnalytics>(), Mock.Of<IDeploymentManager>(), Mock.Of<IDeploymentStatusManager>(),
                                                      opLock.Object, repoFactory.Object, Mock.Of<IAutoSwapHandler>());
            controller.Request = GetRequest();

            // Act
            var response = await Assert.ThrowsAsync<HttpResponseException>(async () => await controller.Deploy());

            // Assert
            Assert.Equal(HttpStatusCode.NotFound, response.Response.StatusCode);
            Assert.Equal(@"{""Message"":""Repository could not be found.""}", await response.Response.Content.ReadAsStringAsync());
        }
Beispiel #2
0
        public async Task RedeployReturns404IfCommitDoesNotExist()
        {
            // Arrange
            var repository = new Mock<IRepository>();
            repository.Setup(r => r.GetChangeSet(It.IsAny<string>()))
                      .Returns((ChangeSet)null);
            var repoFactory = new Mock<IRepositoryFactory>();
            repoFactory.Setup(r => r.GetRepository()).Returns(repository.Object);
            var opLock = new Mock<IOperationLock>();
            opLock.Setup(f => f.Lock()).Returns(true);
            var controller = new DeploymentController(Mock.Of<ITracer>(), Mock.Of<IDeploymentManager>(), Mock.Of<IDeploymentStatusManager>(),
                                                      opLock.Object, repoFactory.Object);
            controller.Request = GetRequest();

            // Act
            var response = await ExceptionAssert.ThrowsAsync<HttpResponseException>(async () => await controller.Deploy("1234"));

            // Assert
            Assert.Equal(HttpStatusCode.NotFound, response.Response.StatusCode);
            Assert.Equal(@"{""Message"":""Deployment '1234' not found.""}", await response.Response.Content.ReadAsStringAsync());
        }