Пример #1
0
 public DoctorController(DrugstoreDbContext context,
                         UserManager <SystemUser> userManager,
                         GetPrescriptionsListUseCase getPrescriptions,
                         GetPrescriptionDetailsUseCase getPrescriptionDetails,
                         GetPrescriptionUseCase getPrescription,
                         GetMedicinesUseCase getMedicines,
                         GetPatientsUseCase getPatients,
                         DeletePrescriptionUseCase deletePrescription,
                         GetTreatmentHistoryUseCase getTreatmentHistory,
                         GetPrescriptionMedicinesUseCase getPrescriptionMedicines,
                         EditPrescriptionUseCase editPrescription,
                         AddPrescriptionUseCase addPrescription)
 {
     this.context                  = context;
     this.userManager              = userManager;
     this.getPrescription          = getPrescription;
     this.getMedicines             = getMedicines;
     this.getPatients              = getPatients;
     this.deletePrescription       = deletePrescription;
     this.getTreatmentHistory      = getTreatmentHistory;
     this.getPrescriptionMedicines = getPrescriptionMedicines;
     this.editPrescription         = editPrescription;
     this.addPrescription          = addPrescription;
     getPrescriptionsList          = getPrescriptions;
     this.getPrescriptionDetails   = getPrescriptionDetails;
 }
Пример #2
0
        public void Should_Delete_Prescription()
        {
            // given
            var expectedResult            = true;
            var expectedPrescriptionCount = context.MedicalPrescriptions.Count() - 1;
            var loggerMock = new Mock <ILogger <DeletePrescriptionUseCase> >();
            var useCase    = new DeletePrescriptionUseCase(context, loggerMock.Object);
            var doctor     = context.Doctors.First();
            var presc      = context.MedicalPrescriptions.First();

            // when
            var actualResult = useCase.Execute(presc.Doctor.ID, presc.ID);

            // then
            Assert.AreEqual(expectedResult, actualResult.Succes);
            Assert.AreEqual(expectedPrescriptionCount, context.MedicalPrescriptions.Count());
        }
Пример #3
0
        public void Should_Not_Delete_Prescription()
        {
            // given
            var expectedResult            = false;
            var expectedPrescriptionCount = context.MedicalPrescriptions.Count();
            var loggerMock = new Mock <ILogger <DeletePrescriptionUseCase> >();
            var useCase    = new DeletePrescriptionUseCase(context, loggerMock.Object);
            var doctor     = context.Doctors.First();
            var presc      = context.MedicalPrescriptions.First();
            var uselessDoc = new Doctor {
                FirstName = "Useless", SecondName = "Doc"
            };

            context.Doctors.Add(uselessDoc);
            context.SaveChanges();

            // when
            var actualResult = useCase.Execute(uselessDoc.ID, presc.ID);

            // then
            Assert.AreEqual(expectedResult, actualResult.Succes);
            Assert.AreEqual(expectedPrescriptionCount, context.MedicalPrescriptions.Count());
        }