public async Task UpdateNote_AsAdmin_ShouldUpdateNote() { // Arrange var note = "new note"; var invitation = await InvitationsControllerTestsHelper.GetInvitationAsync( UserType.Viewer, TestFactory.PlantWithAccess, InitialMdpInvitationId); var participant = invitation.Participants.First(); var dto = new ParticipantToUpdateNoteDto { Id = participant.Id, Note = note, RowVersion = participant.RowVersion }; // Act await InvitationsControllerTestsHelper.UpdateNoteOnParticipantAsync( UserType.Admin, TestFactory.PlantWithAccess, InitialMdpInvitationId, dto); // Assert invitation = await InvitationsControllerTestsHelper.GetInvitationAsync( UserType.Viewer, TestFactory.PlantWithAccess, InitialMdpInvitationId); Assert.AreEqual(invitation.Participants.First().Note, dto.Note); Assert.AreNotEqual(invitation.Participants.First().RowVersion, dto.RowVersion); }
public async Task UpdateNote_AsSigner_ShouldUpdateNote() { // Arrange var(invitationToCompleteId, _) = await CreateValidCompletePunchOutDtoAsync(_participantsForSigning); var invitation = await InvitationsControllerTestsHelper.GetInvitationAsync( UserType.Viewer, TestFactory.PlantWithAccess, invitationToCompleteId); var participant = invitation.Participants.First(); var dto = new ParticipantToUpdateNoteDto { Id = participant.Id, Note = "new note", RowVersion = participant.RowVersion }; // Act await InvitationsControllerTestsHelper.UpdateNoteOnParticipantAsync( UserType.Signer, TestFactory.PlantWithAccess, invitationToCompleteId, dto); // Assert invitation = await InvitationsControllerTestsHelper.GetInvitationAsync( UserType.Viewer, TestFactory.PlantWithAccess, invitationToCompleteId); Assert.AreEqual(invitation.Participants.First().Note, dto.Note); Assert.AreNotEqual(invitation.Participants.First().RowVersion, dto.RowVersion); }
public static async Task UpdateNoteOnParticipantAsync( UserType userType, string plant, int id, ParticipantToUpdateNoteDto 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}/Note", content); await TestsHelper.AssertResponseAsync(response, expectedStatusCode, expectedMessageOnBadRequest); }
public async Task UpdateNote_AsContractor_ShouldUpdateNote() { // Arrange var participants = new List <CreateParticipantsDto>(_participants); var(invitationId, editInvitationDto) = await CreateValidEditInvitationDtoAsync(participants); var dto = new ParticipantToUpdateNoteDto { Id = editInvitationDto.UpdatedParticipants.Last().Person.Id, Note = "new note", 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.UpdateNoteOnParticipantAsync( UserType.Contractor, TestFactory.PlantWithAccess, invitationId, dto); // Assert var invitation = await InvitationsControllerTestsHelper.GetInvitationAsync( UserType.Viewer, TestFactory.PlantWithAccess, invitationId); Assert.AreEqual(invitation.Participants.Last().Note, dto.Note); Assert.AreNotEqual(invitation.Participants.Last().RowVersion, dto.RowVersion); }