public async Task Run_InvalidStatus_ReturnsBadRequest() { // arrange var requestStatus = "test"; var requestBody = $"{{\"status\":\"{requestStatus}\", \"detail\":\"test doc\"}}"; var req = TestFactory.CreateHttpRequest(requestBody); var logger = TestFactory.CreateLogger(LoggerTypes.List); DocumentDetails documentDetails = new DocumentDetails { Id = Guid.NewGuid(), Body = "doc123.txt", CreatedOn = DateTime.UtcNow }; // act var result = await DocumentPutCallback.Run(req, documentDetails.Id.ToString(), documentDetails, logger); // assert result.Should().BeOfType <BadRequestObjectResult>(); documentDetails.Status.Should().HaveCount(0); }
public async Task Run_WithValidRequest_ReturnsUpdatesDb() { // arrange var requestStatus = "PROCESSED"; var requestBody = $"{{\"status\":\"{requestStatus}\", \"detail\":\"processed doc\"}}"; var req = TestFactory.CreateHttpRequest(requestBody); var logger = TestFactory.CreateLogger(LoggerTypes.List); DocumentDetails documentDetails = new DocumentDetails { Id = Guid.NewGuid(), Body = "doc123.txt", CreatedOn = DateTime.UtcNow }; // act var result = await DocumentPutCallback.Run(req, documentDetails.Id.ToString(), documentDetails, logger); // assert result.Should().BeOfType <NoContentResult>(); documentDetails.Status.Should().HaveCount(1); documentDetails.Status[0].Status.Should().Be(requestStatus); }