public async Task ShouldPutAValidAppointment() { // arrange; // appointment with this ID exists in the test data set so can be modified; var appointmentId = new Guid("134f3726-3369-492b-b3bd-b62be67b96f8"); var command = new Put.Command( appointmentId, "auth0|6076cf2ec42780006af85a96", new(2021, 7, 1, 10, 0, 0), 60, null, "ADDED_NOTES"); // the only actual modification, but PUT requires entire object;); const string expectedPatientNotes = "ADDED_NOTES"; // act; var res = await SendMediatorRequestInScopeOnBehalfOfTheTestPatient(command); // lets also check with a GET that the modification did in fact apply; var resObject = await SendMediatorRequestInScopeOnBehalfOfTheTestPatient(new GetOne.Query(appointmentId)); // assert; res.Should().BeOfType <NoContentResult>(); // successful PUT should return NO CONTENT per HTTP conventions; resObject? .PatientNotes .Should() .NotBeNull() .And.BeEquivalentTo(expectedPatientNotes); // clean up the DB, i.e. revert it to the original state; var appointmentToCleanUp = Context.Appointments.FirstOrDefault(a => a.AppointmentId == appointmentId); appointmentToCleanUp !.PatientNotes = null; await Context.SaveChangesAsync(); }
public async Task ShouldReturnUnauthorizedIfPatientTriesToAssignAnExistingAppointmentToADifferentDoctor() { // arrange; // appointment with this ID exists in the test data set so can be modified; var appointmentId = new Guid("134f3726-3369-492b-b3bd-b62be67b96f8"); var command = new Put.Command( appointmentId, "SOME_OTHER_DOCTOR", // the only actual modification, but PUT requires entire object; new(2021, 7, 1, 10, 0, 0), 60, null, null); // act; var res = await SendMediatorRequestInScopeOnBehalfOfTheTestPatient(command); // assert; res.Should().BeOfType <UnauthorizedResult>(); }