Exemplo n.º 1
0
        public void Should_Not_Edit_Prescription_No_Meds()
        {
            // given
            var expectedResult            = false;
            var expectedPrescriptionCount = context.MedicalPrescriptions.Count();
            var loggerMock = new Mock <ILogger <EditPrescriptionUseCase> >();
            var useCase    = new EditPrescriptionUseCase(context, loggerMock.Object);
            var doctor     = context.Doctors.First();

            var meds = new MedicineViewModel [] { };
            // when
            var actualResult = useCase.Execute(meds, context.MedicalPrescriptions.First().ID, doctor.ID);

            // then
            Assert.AreEqual(expectedResult, actualResult.Succes);
        }
Exemplo n.º 2
0
        public JsonResult EditMedicines([FromBody] MedicineViewModel [] medicines, int prescriptionId)
        {
            ResultViewModel result   = null;
            var             systemId = userManager.GetUserAsync(User).Result.Id;
            var             doctor   = context.Doctors.FirstOrDefault(d => d.SystemUser.Id == systemId);

            if (ModelState.IsValid && medicines.Length > 0)
            {
                result = editPrescription.Execute(medicines, prescriptionId, doctor.ID);
            }
            else
            {
                result = new ResultViewModel {
                    Succes = false, Message = "Normy recepty nie zostały spełnione"
                };
            }

            return(Json(result));
        }
Exemplo n.º 3
0
        public void Should_Edit_Prescription()
        {
            // given
            var expectedResult            = true;
            var expectedPrescriptionCount = context.MedicalPrescriptions.Count();
            var loggerMock = new Mock <ILogger <EditPrescriptionUseCase> >();
            var useCase    = new EditPrescriptionUseCase(context, loggerMock.Object);
            var doctor     = context.Doctors.First();
            var onlyMed    = Map <MedicineViewModel>(context.Medicines.First());

            onlyMed.Quantity = 5;


            var meds = new MedicineViewModel [] { onlyMed };
            // when
            var actualResult = useCase.Execute(meds, context.MedicalPrescriptions.First().ID, doctor.ID);

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