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; }
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()); }
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()); }