public async void SaveClinicalDocumentReturnsBadRequest() { var mockIMapper = new Mock <IMapper>(); var mockIClinicalDocumentBusinessLogic = new Mock <IClinicalDocumentBusinessLogic>(); Mock <IStringLocalizer <SharedResources> > mockIClinicalDocumentControllerLocalizer = new Mock <IStringLocalizer <SharedResources> >(); mockIMapper.Setup(m => m.Map <ClinicalDocumentInputModel>(It.IsAny <object>())).Returns(TestConstants.ClinicalDocumentInputModel); mockIMapper.Setup(m => m.Map <DocumentDetailResponse>(It.IsAny <object>())).Returns(TestConstants.DocResponse); mockIClinicalDocumentBusinessLogic.Setup(x => x.SaveClinicalDetails(TestConstants.ClinicalDocumentInputModel)).ReturnsAsync(TestConstants.ClinicalDocumentOutputModelNull); var clinicalDocumentController = new ClinicalDocumentController(mockIClinicalDocumentBusinessLogic.Object, mockIMapper.Object, mockIClinicalDocumentControllerLocalizer.Object); var result = await clinicalDocumentController.SaveClinicaldetails(TestConstants.DocRequest); Assert.IsType <BadRequestObjectResult>(result); }
public async void SaveClinicalDocumentOkResult() { var mockIMapper = new Mock <IMapper>(); var mockIClinicalDocumentBusinessLogic = new Mock <IClinicalDocumentBusinessLogic>(); Mock <IStringLocalizer <SharedResources> > mockIClinicalDocumentControllerLocalizer = new Mock <IStringLocalizer <SharedResources> >(); mockIMapper.Setup(m => m.Map <ClinicalDocumentInputModel>(It.IsAny <object>())).Returns(TestConstants.ClinicalDocumentInputModel); mockIMapper.Setup(m => m.Map <DocumentDetailResponse>(It.IsAny <object>())).Returns(TestConstants.DocResponse); mockIClinicalDocumentBusinessLogic.Setup(x => x.SaveClinicalDetails(TestConstants.ClinicalDocumentInputModel)).ReturnsAsync(TestConstants.ClinicalDocumentOutputModel); var clinicalDocumentController = new ClinicalDocumentController(mockIClinicalDocumentBusinessLogic.Object, mockIMapper.Object, mockIClinicalDocumentControllerLocalizer.Object); var result = await clinicalDocumentController.SaveClinicaldetails(TestConstants.DocRequest); var responseMessage = ((DocumentDetailResponse)((Microsoft.AspNetCore.Mvc.ObjectResult)result).Value).ResponseMessage; Assert.Equal("Record : 465A6717 - 9956 - 4DC3 - 8C94 - FE9B09CB2B84 saved successfully.", responseMessage); }