Example #1
0
 public void Arrange()
 {
     _sucessBuildId   = "827572";
     _teamCityService = Substitute.For <ITeamCityService>();
     _teamCityService.GetBuildStatus(_sucessBuildId).Returns("SUCCESS");
     _testEnvironmentService        = Substitute.For <ITestEnvironmentService>();
     _buildStatusDataStorageService = Substitute.For <IBuildStatusDataStorageService>();
     _updateBuildStatusController   = new UpdateBuildStatusController(_teamCityService, _testEnvironmentService, _buildStatusDataStorageService);
     SetupController(HttpMethod.Post);
 }
Example #2
0
        public void When_there_is_an_exception_a_400_Response_Is_Sent_Back()
        {
            //Arrange
            _teamCityService.GetBuildStatus(Arg.Any <string>()).Returns(x => { throw new Exception(); });

            //Act
            var response = _updateBuildStatusController.Post(_sucessBuildId);

            //Assert
            Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode);
        }
Example #3
0
        public HttpResponseMessage Post([FromUri] string id)
        {
            try
            {
                var status = _teamCityService.GetBuildStatus(id);

                var buildNumber = _testEnvironmentService.GetBuildVersion("135");

                var result = _buildStatusDataStorageService.StoreSanityBuildInformation(buildNumber, status);

                var response = Request.CreateResponse(HttpStatusCode.Created);

                return(response);
            }
            catch (Exception)
            {
                var response = Request.CreateResponse(HttpStatusCode.BadRequest);

                return(response);
            }
        }