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));
        }
示例#2
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]);
        }
示例#4
0
        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));
        }
示例#5
0
        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));
        }
示例#6
0
        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));
        }
示例#7
0
        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);
        }
示例#8
0
        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));
        }
示例#9
0
        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));
        }