public void GetCaseReportById_ItemDoesNotExists_KeyNotFoundException() { // Arrange var(unitOfWork, caseReportRepo, dbCollectionCaseReport) = GetMocks(); var service = new CaseReportService(unitOfWork.Object); // Act + Assert Assert.ThrowsAsync <KeyNotFoundException>(async() => await service.GetCaseReportById(0)); }
public void CreateCaseReport_NullObject_NullReferenceException() { // Arrange var(unitOfWork, caseReportRepo, dbCollection) = GetMocks(); var service = new CaseReportService(unitOfWork.Object); // Act + Assert Assert.ThrowsAsync <NullReferenceException>(async() => await service.CreateCaseReport(null)); }
public async Task GetCaseReportById_ItemExists_Success() { // Arrange var(unitOfWork, caseReportRepo, dbCollectionCaseReport) = GetMocks(); var service = new CaseReportService(unitOfWork.Object); // Act var caseReport = await service.GetCaseReportById(27); // Assert Assert.AreEqual(caseReport, dbCollectionCaseReport[27]); }
public void UpdateCaseReport_EmptyFullName_InvalidDataException() { // Arrange var(unitOfWork, caseReportRepo, dbCollectionCaseReport) = GetMocks(); var service = new CaseReportService(unitOfWork.Object); var caseReport = new CaseReport() { Diagnosis = "" }; // Act + Assert Assert.ThrowsAsync <InvalidDataException>(async() => await service.UpdateCaseReport(27, caseReport)); }
public void UpdateCaseReport_NoItemForUpdate_NullReferenceException() { // Arrange var(unitOfWork, caseReportRepo, dbCollectionCaseReport) = GetMocks(); var service = new CaseReportService(unitOfWork.Object); var caseReport = new CaseReport() { Diagnosis = "Update Track" }; // Act + Assert Assert.ThrowsAsync <NullReferenceException>(async() => await service.UpdateCaseReport(0, caseReport)); }
public void DeleteCaseReport_ItemDoesNotExists_NullReferenceException() { // Arrange var(unitOfWork, caseReportRepo, dbCollectionCaseReport) = GetMocks(); var service = new CaseReportService(unitOfWork.Object); var caseReport = new CaseReport { Id = 0, Diagnosis = "Delete Diagnosis" }; // Act + Assert Assert.ThrowsAsync <NullReferenceException>(async() => await service.DeleteCaseReport(caseReport)); }
public async Task UpdateCaseReport_FullInfo_Success() { // Arrange var(unitOfWork, caseReportRepo, dbCollectionCaseReport) = GetMocks(); var service = new CaseReportService(unitOfWork.Object); var caseReport = new CaseReport { PatientId = 27, Diagnosis = "New Diagnosis" }; // Act await service.UpdateCaseReport(27, caseReport); // Assert Assert.AreEqual((await unitOfWork.Object.CaseReports.GetWithPatientByIdAsync(27)).Diagnosis, caseReport.Diagnosis); }
public async Task DeleteCaseReport_TargetItem_Success() { // Arrange var(unitOfWork, caseReportRepo, dbCollectionCaseReport) = GetMocks(); var service = new CaseReportService(unitOfWork.Object); var caseReport = new CaseReport { Id = 26, Diagnosis = "Delete Diagnosis" }; // Act await service.DeleteCaseReport(caseReport); // Assert Assert.IsFalse(dbCollectionCaseReport.ContainsKey(26)); }
public async Task CreateCaseReport_FullInfo_Success() { // Arrange var(unitOfWork, caseReportRepo, dbCollection) = GetMocks(); var service = new CaseReportService(unitOfWork.Object); var caseReport = new CaseReport { Id = 28, Diagnosis = "New Diagnosis", Description = "New Description" }; // Act await service.CreateCaseReport(caseReport); // Assert Assert.IsTrue(dbCollection.ContainsKey(caseReport.Id)); }