Example #1
0
        public async Task GetCaseDetails_NotFound()
        {
            // Arrange
            int caseId = 1;
            CaseDetailsModel expected = null;

            _mockCourtCasesService.RetrieveAsync(caseId).Returns(expected);

            // Act
            ActionResult <CaseDetailsModel> response = await _sut.GetCaseDetails(caseId);

            // Assert
            await _mockCourtCasesService.Received(1).RetrieveAsync(caseId);

            Assert.IsType <NotFoundResult>(response.Result);
        }
Example #2
0
        public async Task <ActionResult <CaseDetailsModel> > GetCaseDetails(int caseId)
        {
            if (caseId < 1)
            {
                return(UnprocessableEntity($"Invalid CaseId: {caseId}"));
            }
            CaseDetailsModel caseDetails = await _courtCasesService.RetrieveAsync(caseId);

            if (caseDetails is null)
            {
                return(NotFound());
            }
            return(Ok(caseDetails));
        }