Ejemplo n.º 1
0
        public async void CreateQueueItems_WhenAnExceptionOccurs_ShouldReturnBadRequest(string exceptionMessage)
        {
            A.CallTo(() => _serviceBusMessageWriter.WriteMessagesToKedaQueue(A <int> ._)).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> CreateQueueItems(int numberOfQueueItems)
        {
            try
            {
                await _serviceBusMessageWriter.WriteMessagesToKedaQueue(numberOfQueueItems);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }

            return(Ok());
        }