public async Task MainAsync(string[] args) { LogManager.LoadConfiguration("nlog.config"); ILoggerFactory loggerFactory = new NLogLoggerFactory(); var logger = loggerFactory.CreateLogger <Program>(); try { var configuration = CreateConfigurationObject(); var clinicalDocumentAPIConfig = new ClinicalDocumentAPIConfig(); configuration.Bind(clinicalDocumentAPIConfig); var options = Options.Create(clinicalDocumentAPIConfig); _restClinicalDocumentAPI = new RestClinicalDocumentAPI(options, loggerFactory); _documentDetailRequest = CreateDocumentDetailRequest(); //POST endpoint of clinical document - Save Clinical Documents var saveClinicalDocumentsResult = await _restClinicalDocumentAPI.SaveClinicalDocumentDetails(_documentDetailRequest); //GET endpoint of clinical document - Get Clinical Documents var getClinicalDocumentsResult = await _restClinicalDocumentAPI.GetClinicalDocumentDetails("TEST", "12345"); } catch (Exception ex) { logger.LogError(ex, "Exception at Clinical Document Console application"); Console.WriteLine(ex); } }
public async void ThrowsExceptionFromSaveClinicalDocumentDetailsWhenURLIsInvalid() { var mockILogger = new Mock <ILoggerFactory>(); var mockIOptionsClinicalDocumentAPIConfig = new Mock <IOptions <ClinicalDocumentAPIConfig> >(); var mockIRestClinicalDocumentAPI = new Mock <IRestClinicalDocumentAPI>(); DocumentDetailRequest documentDetailRequest = CreateDocumentDetailRequestObject(); SetClinicalDocumentApiConfig(inValidUrl, mockIOptionsClinicalDocumentAPIConfig); var documentDetailResponse = new DocumentDetailResponse { ResponseMessage = "Success" }; var restClinicalDocumentAPI = new RestClinicalDocumentAPI(mockIOptionsClinicalDocumentAPIConfig.Object, mockILogger.Object); await Assert.ThrowsAsync <NullReferenceException>(() => restClinicalDocumentAPI.SaveClinicalDocumentDetails(documentDetailRequest)); }
public async void SaveClinicalDocumentDetails() { var mockILogger = new Mock <ILoggerFactory>(); var mockIOptionsClinicalDocumentAPIConfig = new Mock <IOptions <ClinicalDocumentAPIConfig> >(); var mockIRestClinicalDocumentAPI = new Mock <IRestClinicalDocumentAPI>(); DocumentDetailRequest documentDetailRequest = CreateDocumentDetailRequestObject(); SetClinicalDocumentApiConfig(validUrl, mockIOptionsClinicalDocumentAPIConfig); var documentDetailResponse = new DocumentDetailResponse { ResponseMessage = "Success" }; var restClinicalDocumentAPI = new RestClinicalDocumentAPI(mockIOptionsClinicalDocumentAPIConfig.Object, mockILogger.Object); var result = await restClinicalDocumentAPI.SaveClinicalDocumentDetails(documentDetailRequest); Assert.True(result.IsValid); Assert.True(result.ResponseMessage.Length > 0); Assert.Contains("successfully", result.ResponseMessage); }
public async void SaveClinicalDocumentDetailsReturnsBadRequestWhenParameterPassedIsInvalid() { var mockILogger = new Mock <ILoggerFactory>(); var mockIOptionsClinicalDocumentAPIConfig = new Mock <IOptions <ClinicalDocumentAPIConfig> >(); DocumentDetailRequest documentDetailRequest = CreateDocumentDetailRequestObject(); documentDetailRequest.FacilityCode = "TESTWA"; SetClinicalDocumentApiConfig(validUrl, mockIOptionsClinicalDocumentAPIConfig); var documentDetailResponse = new DocumentDetailResponse { ResponseMessage = "Success" }; var restClinicalDocumentAPI = new RestClinicalDocumentAPI(mockIOptionsClinicalDocumentAPIConfig.Object, mockILogger.Object); var result = await restClinicalDocumentAPI.SaveClinicalDocumentDetails(documentDetailRequest); Assert.True((!result.IsValid)); Assert.Equal("Validation Failed", result.ValidationResponse.Message); }