public async void ProcessQueueItems_WhenAnExceptionOccurs_ShouldReturnBadRequest(string exceptionMessage) { A.CallTo(() => _serviceBusMessageReceiver.ReceiveMessagesFromKedaQueue()).Throws(new ArgumentException(exceptionMessage)); var result = await _testee.ProcessQueueItems(); (result.Result as StatusCodeResult)?.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); (result.Result as BadRequestObjectResult)?.Value.Should().Be(exceptionMessage); }
public async Task <ActionResult <int> > ProcessQueueItems() { var messagesReceived = 0; try { messagesReceived = await _serviceBusMessageReceiver.ReceiveMessagesFromKedaQueue(); } catch (Exception ex) { return(BadRequest(ex.Message)); } return(Ok(messagesReceived)); }