public async void Read_Inactive() { var controller = new NrlsController(_nrlsSettings, _nrlsSearch, _nrlsMaintain); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = HttpContexts.Inactive_Search; var response = await controller.Read("logicalId"); Assert.IsType <BadRequestObjectResult>(response); var result = response as BadRequestObjectResult; Assert.Equal(400, result.StatusCode); var responseContent = result.Value; Assert.IsType <OperationOutcome>(responseContent); var outcome = responseContent as OperationOutcome; Assert.Equal(1, outcome.Errors); }
public async void Read_NotFound() { var controller = new NrlsController(_nrlsSettings, _nrlsSearch, _nrlsMaintain); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = HttpContexts.NotFound_Search; var response = await controller.Read("logicalId"); Assert.IsType <NotFoundObjectResult>(response); var notFoundResult = response as NotFoundObjectResult; Assert.Equal(404, notFoundResult.StatusCode); var responseContent = notFoundResult.Value; Assert.IsType <OperationOutcome>(responseContent); var outcome = responseContent as OperationOutcome; Assert.False(outcome.Success); }
public async void Read_Found() { var controller = new NrlsController(_nrlsSettings, _nrlsSearch, _nrlsMaintain); controller.ControllerContext = new ControllerContext(); controller.ControllerContext.HttpContext = HttpContexts.Valid_Search; var response = await controller.Read("logicalId"); Assert.IsType <OkObjectResult>(response); var okResult = response as OkObjectResult; Assert.Equal(200, okResult.StatusCode); var responseContent = okResult.Value; Assert.IsType <DocumentReference>(responseContent); var outcome = responseContent as DocumentReference; Assert.Equal(ResourceType.DocumentReference, outcome.ResourceType); Assert.Equal("https://directory.spineservices.nhs.uk/STU3/Organization/1XR", outcome.Custodian.Reference); Assert.Equal("https://demographics.spineservices.nhs.uk/STU3/Patient/2686033207", outcome.Subject.Reference); }