Exemple #1
0
        public async Task ShouldCancelAnAppointmentIfFound()
        {
            // arrange;
            // prepare an appointment to cancel;
            var appointmentToCancel = new Appointment(
                TestUserHelper.TestPatientId,
                "auth0|6076cf2ec42780006af85a96",
                new(2021, 10, 10, 15, 0, 0),
                60,
                "SOME_DOCTOR_NOTES",
                "SOME_PATIENT_NOTES");
            await Context.Appointments.AddAsync(appointmentToCancel);

            await Context.SaveChangesAsync();

            // prepare the CQRS MediatR (mediator) command;
            var command        = new Cancel.Command(appointmentToCancel.AppointmentId);
            var getObjectQuery = new GetOne.Query(appointmentToCancel.AppointmentId);

            // res should be of type NoContentResult;
            // resObject should return null because the object no longer exists (cancelled);

            // act;
            var res = await SendMediatorRequestInScopeOnBehalfOfTheTestPatient(command);

            var resObject = await SendMediatorRequestInScopeOnBehalfOfTheTestPatient(getObjectQuery);

            // assert;
            res.Should().BeOfType <NoContentResult>();
            resObject.Should().BeNull();

            // no need to clean up the DB as we've just cancelled (deleted) the appointment;
        }
Exemple #2
0
        public async Task ShouldDeleteBmIfFound()
        {
            // arrange;
            // prepare a bm to delete;
            var bmToDelete = new BowelMovementEvent
            {
                PatientId      = TestUserHelper.TestPatientId,
                ContainedBlood = true,
                ContainedMucus = true,
                DateTime       = DateTime.Now
            };
            await Context.BowelMovementEvents.AddAsync(bmToDelete);

            await Context.SaveChangesAsync();

            // prepare the CQRS command;
            var command        = new Delete.Command(bmToDelete.BowelMovementEventId);
            var getObjectQuery = new GetOne.Query(bmToDelete.BowelMovementEventId);

            // res should be of type NoContentResult;
            // resObject should return null because the object no longer exists (deleted);

            var res = await SendMediatorRequestInScopeOnBehalfOfTheTestPatient(command);

            var resObject = await SendMediatorRequestInScopeOnBehalfOfTheTestPatient(getObjectQuery);

            // assert;
            res.Should().BeOfType <NoContentResult>();
            resObject.Should().BeNull();

            // no need to clean up the DB as we've just deleted the BM we've added;
        }
Exemple #3
0
        public async Task <ActionResult <AppointmentDto> > GetOneForMeById([FromRoute] GetOne.Query query)
        {
            var res = await _mediator.Send(query);

            return(res is null?NotFound() : Ok(res));
        }
        public async Task <ActionResult <BowelMovementEventDto> > GetOneForMeById(GetOne.Query query)
        {
            var res = await _mediator.Send(query);

            return(res is null?NotFound() : Ok(res));
        }