public async Task UXO_GetAllHasAnError_ShouldReturnInternalServerError() { var mockUxoService = new Mock <IUXOService>(); var mockUxoDocumentService = new Mock <IUXODocumentService>(); mockUxoService.Setup(svc => svc.GetUXOsForDisplay()) .ThrowsAsync(new Exception()); var controller = new UxoController(mockUxoService.Object, mockUxoDocumentService.Object, _logger); var result = await controller.GetUXOs(); var actionResult = Assert.IsType <ActionResult <List <UXOMapItem> > >(result); var objectResult = Assert.IsType <ObjectResult>(actionResult.Result); Assert.Equal((int)HttpStatusCode.InternalServerError, objectResult.StatusCode); }
public async Task UXO_GetAllWithNoExceptions_ShouldReturnOk() { var mockUxoService = new Mock <IUXOService>(); var mockUxoDocumentService = new Mock <IUXODocumentService>(); mockUxoService.Setup(svc => svc.GetUXOsForDisplay()) .ReturnsAsync(SampleData.SampleMapItems()); var controller = new UxoController(mockUxoService.Object, mockUxoDocumentService.Object, _logger); var result = await controller.GetUXOs(); var actionResult = Assert.IsType <ActionResult <List <UXOMapItem> > >(result); var objectResult = Assert.IsType <OkObjectResult>(actionResult.Result); Assert.IsType <List <UXOMapItem> >(objectResult.Value); }