public async Task UpdateAttendedStatus_AsAdmin_ShouldUpdateAttendedStatus() { // Arrange var invitation = await InvitationsControllerTestsHelper.GetInvitationAsync( UserType.Viewer, TestFactory.PlantWithAccess, InitialMdpInvitationId); var participant = invitation.Participants.First(); var dto = new ParticipantToUpdateAttendedStatusDto { Id = participant.Id, Attended = !participant.Attended, RowVersion = participant.RowVersion }; // Act await InvitationsControllerTestsHelper.UpdateAttendedStatusOnParticipantAsync( UserType.Admin, TestFactory.PlantWithAccess, InitialMdpInvitationId, dto); // Assert invitation = await InvitationsControllerTestsHelper.GetInvitationAsync( UserType.Viewer, TestFactory.PlantWithAccess, InitialMdpInvitationId); Assert.AreEqual(invitation.Participants.First().Attended, dto.Attended); Assert.AreNotEqual(invitation.Participants.First().RowVersion, dto.RowVersion); }
public async Task UpdateAttendedStatus_AsSigner_ShouldUpdateAttendedStatus() { // Arrange var(invitationToCompleteId, _) = await CreateValidCompletePunchOutDtoAsync(_participantsForSigning); var invitation = await InvitationsControllerTestsHelper.GetInvitationAsync( UserType.Viewer, TestFactory.PlantWithAccess, invitationToCompleteId); var participant = invitation.Participants.First(); var dto = new ParticipantToUpdateAttendedStatusDto { Id = participant.Id, Attended = !participant.Attended, RowVersion = participant.RowVersion }; // Act await InvitationsControllerTestsHelper.UpdateAttendedStatusOnParticipantAsync( UserType.Signer, TestFactory.PlantWithAccess, invitationToCompleteId, dto); // Assert invitation = await InvitationsControllerTestsHelper.GetInvitationAsync( UserType.Viewer, TestFactory.PlantWithAccess, invitationToCompleteId); Assert.AreEqual(invitation.Participants.First().Attended, dto.Attended); Assert.AreNotEqual(invitation.Participants.First().RowVersion, dto.RowVersion); }
public static async Task UpdateAttendedStatusOnParticipantAsync( UserType userType, string plant, int id, ParticipantToUpdateAttendedStatusDto dto, HttpStatusCode expectedStatusCode = HttpStatusCode.OK, string expectedMessageOnBadRequest = null) { var serializePayload = JsonConvert.SerializeObject(dto); var content = new StringContent(serializePayload, Encoding.UTF8, "application/json"); var response = await TestFactory.Instance.GetHttpClient(userType, plant) .PutAsync($"{Route}/{id}/AttendedStatus", content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); }
public async Task UpdateAttendedStatus_AsContractor_ShouldUpdateAttendedStatus() { // Arrange var participants = new List <CreateParticipantsDto>(_participants); var(invitationId, editInvitationDto) = await CreateValidEditInvitationDtoAsync(participants); var dto = new ParticipantToUpdateAttendedStatusDto { Id = editInvitationDto.UpdatedParticipants.Last().Person.Id, Attended = true, RowVersion = editInvitationDto.UpdatedParticipants.Last().Person.RowVersion }; TestFactory.Instance .PersonApiServiceMock .Setup(x => x.GetPersonInFunctionalRoleAsync( TestFactory.PlantWithAccess, _contractor.AsProCoSysPerson().AzureOid, participants.First().FunctionalRole.Code)) .Returns(Task.FromResult(_contractor.AsProCoSysPerson())); // Act await InvitationsControllerTestsHelper.UpdateAttendedStatusOnParticipantAsync( UserType.Contractor, TestFactory.PlantWithAccess, invitationId, dto); // Assert var invitation = await InvitationsControllerTestsHelper.GetInvitationAsync( UserType.Viewer, TestFactory.PlantWithAccess, invitationId); Assert.AreEqual(invitation.Participants.Last().Attended, dto.Attended); Assert.AreNotEqual(invitation.Participants.Last().RowVersion, dto.RowVersion); }