コード例 #1
0
        public async Task ShouldPutAValidBm()
        {
            // arrange;
            // test data set contains this BM;
            var bmGuid   = new Guid("f8cc02c9-9fb4-4b5f-9611-e10b301233ff");
            var dateTime = new DateTime(2021, 5, 1, 15, 0, 0);
            var command  = new Put.Command(bmGuid, dateTime, true, false);

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

            var resObj = await SendMediatorRequestInScopeOnBehalfOfTheTestPatient(new GetOne.Query(bmGuid));

            // assert;
            res.Should().BeOfType <NoContentResult>();
            resObj?
            .ContainedMucus
            .Should()
            .BeFalse();

            // clean up the DB, i.e. revert it to the original state;
            var bmToCleanUp = await Context.BowelMovementEvents
                              .FirstOrDefaultAsync(bm => bm.BowelMovementEventId == bmGuid);

            bmToCleanUp !.ContainedMucus = true;
            await Context.SaveChangesAsync();
        }
コード例 #2
0
        public async Task <ActionResult> Put([FromRoute] Guid id, [FromBody] Put.Command command)
        {
            if (id != command.GlobalNotificationId)
            {
                return(BadRequest());
            }

            return(await _mediator.Send(command));
        }
コード例 #3
0
        public async Task <ActionResult> PutForMe([FromRoute] Guid appointmentId, [FromBody] Put.Command command)
        {
            if (appointmentId != command.AppointmentId)
            {
                return(BadRequest());
            }

            return(await _mediator.Send(command));
        }
コード例 #4
0
        public async Task <ActionResult> Put([FromRoute] Guid informationRequestId, [FromBody] Put.Command command)
        {
            if (informationRequestId != command.InformationRequestId)
            {
                return(BadRequest());
            }

            return(await _mediator.Send(command));
        }
コード例 #5
0
        public async Task ShouldReturnNotFoundResultIfNotFound()
        {
            // arrange;
            // test data set does not contain this BM;
            // empty Guid, no BM will have that, which is what we want, since we are testing
            // what happens if appointment isn't found;
            var bmGuid  = new Guid();
            var command = new Put.Command(bmGuid, DateTime.UtcNow, false, false);

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

            // assert;
            res.Should().BeOfType <NotFoundResult>();
        }
コード例 #6
0
ファイル: PutTests.cs プロジェクト: TraceLD/IbdTracker
        public async Task PutShouldReturnNotFoundResultIfNotFound()
        {
            // arrange;
            // test data set contains this Appointment;
            // empty Guid, no appointment will have that, which is what we want, since we are testing
            // what happens if appointment isn't found;
            var appointmentId = new Guid();
            var command       = new Put.Command(
                appointmentId,
                "DOES_NOT_MATTER_AS_APPOINTMENT_ID_DOES_NOT_EXIST",
                DateTime.Today, // does not matter either;
                60,             // does not matter either;
                null,           // does not matter either;
                null            // does not matter either;
                );

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

            // assert;
            res.Should().BeOfType <NotFoundResult>();
        }
コード例 #7
0
        public async Task ShouldPutValidSettings()
        {
            // arrange;
            // the value in the test data set is "true", so we will change it to "false";
            const bool startingValue    = true;
            const bool expectedNewValue = false; // + expected return type from command = NoContentResult;
            var        command          = new Put.Command(false);

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

            var newValue = await Context.PatientApplicationSettings
                           .Where(s => s.PatientId.Equals(TestUserHelper.TestPatientId))
                           .FirstOrDefaultAsync();

            // assert;
            res.Should().BeOfType <NoContentResult>();
            newValue.ShareDataForResearch.Should().Be(expectedNewValue);

            // clean up the db;
            // reset to starting value;
            newValue.ShareDataForResearch = startingValue;
            await Context.SaveChangesAsync();
        }
コード例 #8
0
 public async Task <ActionResult> PutForMe(Put.Command command) =>
 await _mediator.Send(command);
コード例 #9
0
        public async Task <ActionResult> PutForMe([FromRoute] Guid bowelMovementEventId, [FromBody] Put.Command command)
        {
            if (bowelMovementEventId != command.BowelMovementEventId)
            {
                return(BadRequest());
            }

            return(await _mediator.Send(command));
        }
コード例 #10
0
 public async Task <ActionResult <Unit> > Put([FromBody] Put.Command command)
 {
     return(await Mediator.Send(command));
 }