Пример #1
0
        public async Task UnsignPunchOut_AsSigner_ShouldUnsignPunchOut()
        {
            // Arrange
            var(invitationToSignAndUnsignId, editInvitationDto) = await CreateValidEditInvitationDtoAsync(_participantsForSigning);

            var participant = editInvitationDto.UpdatedParticipants.Single(p => p.Organization == Organization.TechnicalIntegrity);

            var currentRowVersion = await InvitationsControllerTestsHelper.SignPunchOutAsync(
                UserType.Signer,
                TestFactory.PlantWithAccess,
                invitationToSignAndUnsignId,
                participant.Person.Id,
                participant.Person.RowVersion);

            // Act
            var newRowVersion = await InvitationsControllerTestsHelper.UnsignPunchOutAsync(
                UserType.Signer,
                TestFactory.PlantWithAccess,
                invitationToSignAndUnsignId,
                participant.Person.Id,
                currentRowVersion);

            // Assert
            var unsignedInvitation = await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Signer,
                TestFactory.PlantWithAccess,
                invitationToSignAndUnsignId);

            var signerParticipant = unsignedInvitation.Participants.Single(p => p.Id == participant.Person.Id);

            Assert.IsNull(signerParticipant.SignedAtUtc);
            Assert.IsNull(signerParticipant.SignedBy);
            AssertRowVersionChange(currentRowVersion, newRowVersion);
        }
Пример #2
0
        public async Task CancelPunchOut_AsContractor_ShouldCancelPunchOut()
        {
            // Arrange
            var(invitationToCancelId, cancelPunchOutDto) = await CreateValidCancelPunchOutDtoAsync(_participants);

            TestFactory.Instance
            .PersonApiServiceMock
            .Setup(x => x.GetPersonInFunctionalRoleAsync(
                       TestFactory.PlantWithAccess,
                       _contractor.AsProCoSysPerson().AzureOid,
                       "FRCA"))
            .Returns(Task.FromResult(_contractor.AsProCoSysPerson()));

            // Act
            var newRowVersion = await InvitationsControllerTestsHelper.CancelPunchOutAsync(
                UserType.Contractor,
                TestFactory.PlantWithAccess,
                invitationToCancelId,
                cancelPunchOutDto);

            // Assert
            var canceledInvitation = await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Contractor,
                TestFactory.PlantWithAccess,
                invitationToCancelId);

            Assert.AreEqual(IpoStatus.Canceled, canceledInvitation.Status);
            AssertRowVersionChange(cancelPunchOutDto.RowVersion, newRowVersion);
        }
Пример #3
0
        public async Task EditInvitation_AsPlanner_ShouldEditInvitation()
        {
            // Arrange
            var(invitationId, editInvitationDto) = await CreateValidEditInvitationDtoAsync(_participants);

            var          currentRowVersion  = editInvitationDto.RowVersion;
            const string UpdatedTitle       = "UpdatedInvitationTitle";
            const string UpdatedDescription = "UpdatedInvitationDescription";

            editInvitationDto.Title       = UpdatedTitle;
            editInvitationDto.Description = UpdatedDescription;

            // Act
            var newRowVersion = await InvitationsControllerTestsHelper.EditInvitationAsync(
                UserType.Planner,
                TestFactory.PlantWithAccess,
                invitationId,
                editInvitationDto);

            // Assert
            var updatedInvitation = await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                invitationId);

            AssertRowVersionChange(currentRowVersion, newRowVersion);
            Assert.AreEqual(UpdatedTitle, updatedInvitation.Title);
            Assert.AreEqual(UpdatedDescription, updatedInvitation.Description);
            Assert.AreEqual(_mcPkgScope.Count, updatedInvitation.McPkgScope.Count());
        }
Пример #4
0
        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);
        }
Пример #5
0
        internal async Task <(int, CancelPunchOutDto)> CreateValidCancelPunchOutDtoAsync(List <CreateParticipantsDto> participants, UserType userType = UserType.Planner)
        {
            var id = await InvitationsControllerTestsHelper.CreateInvitationAsync(
                userType,
                TestFactory.PlantWithAccess,
                Guid.NewGuid().ToString(),
                Guid.NewGuid().ToString(),
                InvitationLocation,
                DisciplineType.DP,
                _invitationStartTime,
                _invitationEndTime,
                participants,
                _mcPkgScope,
                null);

            var invitation = await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                id);

            var cancelPunchOutDto = new CancelPunchOutDto
            {
                RowVersion = invitation.RowVersion
            };

            return(id, cancelPunchOutDto);
        }
Пример #6
0
        internal async Task <(int, AcceptPunchOutDto)> CreateValidAcceptPunchOutDtoAsync(List <CreateParticipantsDto> participants)
        {
            var(invitationToCompleteAndAcceptId, completePunchOutDto) = await CreateValidCompletePunchOutDtoAsync(participants);

            await InvitationsControllerTestsHelper.CompletePunchOutAsync(
                UserType.Signer,
                TestFactory.PlantWithAccess,
                invitationToCompleteAndAcceptId,
                completePunchOutDto);

            var completedInvitation = await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Signer,
                TestFactory.PlantWithAccess,
                invitationToCompleteAndAcceptId);

            var accepterParticipant = completedInvitation.Participants
                                      .Single(p => p.Organization == Organization.ConstructionCompany);

            var acceptPunchOutDto = new AcceptPunchOutDto
            {
                InvitationRowVersion  = completedInvitation.RowVersion,
                ParticipantRowVersion = accepterParticipant.RowVersion,
                Participants          = new List <ParticipantToUpdateNoteDto>
                {
                    new ParticipantToUpdateNoteDto
                    {
                        Id         = accepterParticipant.Id,
                        Note       = $"Some note about the punch round or attendee {Guid.NewGuid():B}",
                        RowVersion = accepterParticipant.RowVersion
                    }
                }
            };

            return(invitationToCompleteAndAcceptId, acceptPunchOutDto);
        }
Пример #7
0
        internal async Task <(int, ParticipantToChangeDto[])> CreateValidParticipantToChangeDtosAsync(List <CreateParticipantsDto> participants)
        {
            var(invitationToChangeId, completePunchOutDto) = await CreateValidCompletePunchOutDtoAsync(participants);

            await InvitationsControllerTestsHelper.CompletePunchOutAsync(
                UserType.Signer,
                TestFactory.PlantWithAccess,
                invitationToChangeId,
                completePunchOutDto);

            var completedInvitation = await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Signer,
                TestFactory.PlantWithAccess,
                invitationToChangeId);

            var completerParticipant = completedInvitation.Participants
                                       .Single(p => p.Organization == Organization.Contractor);

            var participantToChangeDtos = new[]
            {
                new ParticipantToChangeDto
                {
                    Id         = completerParticipant.Id,
                    Attended   = false,
                    Note       = $"Some note about the punch round or attendee {Guid.NewGuid():B}",
                    RowVersion = completerParticipant.RowVersion
                }
            };

            return(invitationToChangeId, participantToChangeDtos);
        }
Пример #8
0
        public async Task DeleteInvitation_AsPlanner_ShouldDeleteInvitation()
        {
            // Arrange
            var(invitationToDeleteId, rowVersion) = await CreateValidDeletePunchOutDtoAsync(_participantsForSigning);

            await InvitationsControllerTestsHelper.GetHistoryAsync(
                UserType.Creator,
                TestFactory.PlantWithAccess,
                invitationToDeleteId);

            // Act
            await InvitationsControllerTestsHelper.DeletePunchOutAsync(UserType.Planner, TestFactory.PlantWithAccess,
                                                                       invitationToDeleteId, rowVersion);

            // Assert
            await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Creator,
                TestFactory.PlantWithAccess,
                invitationToDeleteId,
                HttpStatusCode.NotFound);

            await InvitationsControllerTestsHelper.GetHistoryAsync(
                UserType.Creator,
                TestFactory.PlantWithAccess,
                invitationToDeleteId,
                HttpStatusCode.NotFound);
        }
Пример #9
0
        internal async Task <(int, UnCompletePunchOutDto)> CreateValidUnCompletePunchOutDtoAsync(List <CreateParticipantsDto> participants)
        {
            var(invitationToCompleteAndUnCompleteId, completePunchOutDto) = await CreateValidCompletePunchOutDtoAsync(participants);

            await InvitationsControllerTestsHelper.CompletePunchOutAsync(
                UserType.Signer,
                TestFactory.PlantWithAccess,
                invitationToCompleteAndUnCompleteId,
                completePunchOutDto);

            var completedInvitation = await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Signer,
                TestFactory.PlantWithAccess,
                invitationToCompleteAndUnCompleteId);

            var completerParticipant = completedInvitation.Participants
                                       .Single(p => p.Organization == Organization.Contractor);
            var unCompletePunchOutDto = new UnCompletePunchOutDto
            {
                InvitationRowVersion  = completedInvitation.RowVersion,
                ParticipantRowVersion = completerParticipant.RowVersion,
            };

            return(invitationToCompleteAndUnCompleteId, unCompletePunchOutDto);
        }
Пример #10
0
        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);
        }
Пример #11
0
        public async Task ChangeAttendedStatusOnParticipants_AsSigner_ShouldChangeAttendedStatus()
        {
            //Arrange
            var(invitationToChangeId, participantToChangeDtos) = await CreateValidParticipantToChangeDtosAsync(_participantsForSigning);

            var updatedNote = participantToChangeDtos[0].Note;

            //Act
            await InvitationsControllerTestsHelper.ChangeAttendedStatusAndNotesOnParticipantsAsync(
                UserType.Signer,
                TestFactory.PlantWithAccess,
                invitationToChangeId,
                participantToChangeDtos);

            //Assert
            var invitationWithUpdatedAttendedStatus = await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Signer,
                TestFactory.PlantWithAccess,
                invitationToChangeId);

            var completerParticipant = invitationWithUpdatedAttendedStatus.Participants
                                       .Single(p => p.Organization == Organization.Contractor);

            var participant =
                invitationWithUpdatedAttendedStatus.Participants.Single(p => p.Id == completerParticipant.Id);

            Assert.AreEqual(updatedNote, participant.Note);
            Assert.AreEqual(false, participant.Attended);
        }
Пример #12
0
        public async Task UnAcceptPunchOut_AsSigner_ShouldUnAcceptPunchOut()
        {
            // Arrange
            var(invitationToUnAcceptId, unAcceptPunchOutDto) = await CreateValidUnAcceptPunchOutDtoAsync(_participantsForSigning);

            // Act
            var newRowVersion = await InvitationsControllerTestsHelper.UnAcceptPunchOutAsync(
                UserType.Signer,
                TestFactory.PlantWithAccess,
                invitationToUnAcceptId,
                unAcceptPunchOutDto);

            // Assert
            var unAcceptedInvitation = await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                invitationToUnAcceptId);

            var unAccepterParticipant = unAcceptedInvitation.Participants
                                        .Single(p => p.Organization == Organization.ConstructionCompany);

            var unAcceptingParticipant =
                unAcceptedInvitation.Participants.Single(p => p.Id == unAccepterParticipant.Id);

            Assert.AreEqual(IpoStatus.Completed, unAcceptedInvitation.Status);
            Assert.IsNull(unAcceptingParticipant.SignedAtUtc);
            Assert.IsNull(unAcceptingParticipant.SignedBy);
            AssertRowVersionChange(unAcceptPunchOutDto.InvitationRowVersion, newRowVersion);
        }
Пример #13
0
        public async Task AcceptPunchOut_AsSigner_ShouldAcceptPunchOut()
        {
            // Arrange
            var(invitationToAcceptId, acceptPunchOutDto) = await CreateValidAcceptPunchOutDtoAsync(_participantsForSigning);

            // Act
            var newRowVersion = await InvitationsControllerTestsHelper.AcceptPunchOutAsync(
                UserType.Signer,
                TestFactory.PlantWithAccess,
                invitationToAcceptId,
                acceptPunchOutDto);

            // Assert
            var acceptedInvitation = await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Signer,
                TestFactory.PlantWithAccess,
                invitationToAcceptId);

            var acceptingParticipant =
                acceptedInvitation.Participants.Single(p => p.Id == acceptPunchOutDto.Participants.Single().Id);

            Assert.AreEqual(IpoStatus.Accepted, acceptedInvitation.Status);
            Assert.IsNotNull(acceptingParticipant.SignedAtUtc);
            Assert.AreEqual(_sigurdSigner.Oid, acceptingParticipant.SignedBy.AzureOid.ToString());
            AssertRowVersionChange(acceptPunchOutDto.InvitationRowVersion, newRowVersion);
        }
Пример #14
0
        public async Task ExportInvitations_AsViewer_ShouldExportInvitations()
        {
            // Act
            var file = await InvitationsControllerTestsHelper.ExportInvitationsAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                TestFactory.ProjectWithAccess);

            // Assert
            Assert.AreEqual("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", file.ContentType);
        }
Пример #15
0
        public async Task GetInvitations_AsViewer_ShouldGetInvitations()
        {
            // Act
            var invitationResuls = await InvitationsControllerTestsHelper.GetInvitationsAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                TestFactory.ProjectWithAccess);

            // Assert
            Assert.IsTrue(invitationResuls.Invitations.Count > 0);
            Assert.IsTrue(invitationResuls.MaxAvailable > 0);
        }
Пример #16
0
        public async Task GetDpInvitation_AsViewer_ShouldGetInvitation()
        {
            // Act
            var dpInvitation = await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                InitialDpInvitationId);

            // Assert
            Assert.IsNotNull(dpInvitation);
            Assert.IsTrue(dpInvitation.McPkgScope.Any());
            Assert.AreEqual(0, dpInvitation.CommPkgScope.Count());
            Assert.IsNotNull(dpInvitation.RowVersion);
        }
Пример #17
0
        public async Task GetInvitationsByCommPkgNo_AsViewer_ShouldGetInvitations()
        {
            // Act
            var invitations = await InvitationsControllerTestsHelper.GetInvitationsByCommPkgNoAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                KnownTestData.CommPkgNo,
                TestFactory.ProjectWithAccess);

            // Assert
            var invitation = invitations.First();

            Assert.IsTrue(invitations.Count > 0);
            Assert.AreEqual($"{KnownTestData.InvitationTitle} MDP", invitation.Title);
            Assert.AreEqual(KnownTestData.InvitationDescription, invitation.Description);
        }
Пример #18
0
        internal async Task <AttachmentDto> UploadAttachmentAsync(int invitationId)
        {
            var fileToBeUploaded = TestFile.NewFileToBeUploaded();
            await InvitationsControllerTestsHelper.UploadAttachmentAsync(
                UserType.Planner,
                TestFactory.PlantWithAccess,
                invitationId,
                fileToBeUploaded);

            var attachmentDtos = await InvitationsControllerTestsHelper.GetAttachmentsAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                invitationId);

            return(attachmentDtos.Single(t => t.FileName == fileToBeUploaded.FileName));
        }
Пример #19
0
        public async Task GetComments_AsViewer_ShouldGetComments()
        {
            // Act
            var commentDtos = await InvitationsControllerTestsHelper.GetCommentsAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                InitialMdpInvitationId);

            // Assert
            Assert.IsNotNull(commentDtos);
            Assert.IsTrue(commentDtos.Count > 0);

            var comment = commentDtos.Single(c => c.Id == _commentId);

            Assert.IsNotNull(comment.Comment);
            Assert.IsNotNull(comment.RowVersion);
        }
Пример #20
0
        public async Task EditInvitation_AsPlanner_ShouldAddParticipant()
        {
            // Arrange
            var participants = new List <CreateParticipantsDto>(_participants);

            var(invitationId, editInvitationDto) = await CreateValidEditInvitationDtoAsync(participants);

            Assert.AreEqual(2, editInvitationDto.UpdatedParticipants.Count());

            var updatedParticipants = new List <EditParticipantsDto>(editInvitationDto.UpdatedParticipants);

            updatedParticipants.Add(new EditParticipantsDto
            {
                Organization  = Organization.External,
                ExternalEmail = new EditExternalEmailDto
                {
                    Email = "*****@*****.**"
                },
                SortKey = 3
            });
            editInvitationDto.UpdatedParticipants = updatedParticipants;

            const string UpdatedTitle       = "UpdatedInvitationTitle";
            const string UpdatedDescription = "UpdatedInvitationDescription";

            editInvitationDto.Title       = UpdatedTitle;
            editInvitationDto.Description = UpdatedDescription;

            // Act
            await InvitationsControllerTestsHelper.EditInvitationAsync(
                UserType.Planner,
                TestFactory.PlantWithAccess,
                invitationId,
                editInvitationDto);

            // Assert
            var updatedInvitation = await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                invitationId);

            Assert.AreEqual(3, updatedInvitation.Participants.Count());
            Assert.AreEqual(UpdatedTitle, updatedInvitation.Title);
            Assert.AreEqual(UpdatedDescription, updatedInvitation.Description);
            Assert.AreEqual(_mcPkgScope.Count, updatedInvitation.McPkgScope.Count());
        }
Пример #21
0
        public async Task GetAttachments_AsViewer_ShouldGetAttachments()
        {
            // Act
            var attachmentDtos = await InvitationsControllerTestsHelper.GetAttachmentsAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                InitialMdpInvitationId);

            // Assert
            Assert.IsNotNull(attachmentDtos);
            Assert.IsTrue(attachmentDtos.Count > 0);

            var invitationAttachment = attachmentDtos.Single(a => a.Id == _attachmentOnInitialMdpInvitation.Id);

            Assert.IsNotNull(invitationAttachment.FileName);
            Assert.IsNotNull(invitationAttachment.RowVersion);
        }
Пример #22
0
        internal async Task <(int, string)> CreateValidDeletePunchOutDtoAsync(List <CreateParticipantsDto> participants, UserType userType = UserType.Planner)
        {
            var(invitationId, cancelPunchOutDto) = await CreateValidCancelPunchOutDtoAsync(participants, userType);

            await InvitationsControllerTestsHelper.CancelPunchOutAsync(
                UserType.Admin,
                TestFactory.PlantWithAccess,
                invitationId,
                cancelPunchOutDto);

            var canceledInvitation = await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Admin,
                TestFactory.PlantWithAccess,
                invitationId);

            return(invitationId, canceledInvitation.RowVersion);
        }
Пример #23
0
        public async Task GetHistory_AsViewer_ShouldGetHistory()
        {
            // Act
            var historyDtos = await InvitationsControllerTestsHelper.GetHistoryAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                InitialMdpInvitationId);

            // Assert
            Assert.IsNotNull(historyDtos);
            Assert.IsTrue(historyDtos.Count > 0);

            var historyEvent = historyDtos.First();

            Assert.IsNotNull(historyEvent.Description);
            Assert.IsNotNull(historyEvent.EventType);
        }
Пример #24
0
        public async Task GetLatestMdpIpoOnCommPkgsAsync_AsViewer_ShouldGetCommPkgs()
        {
            // Act
            var commPkgs = await InvitationsControllerTestsHelper.GetLatestMdpIpoOnCommPkgsAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                new List <string> {
                KnownTestData.CommPkgNo
            },
                TestFactory.ProjectWithAccess);

            // Assert
            Assert.IsTrue(commPkgs.Count > 0);
            var commPkg = commPkgs.First();

            Assert.AreEqual(KnownTestData.CommPkgNo, commPkg.CommPkgNo);
            Assert.IsFalse(commPkg.IsAccepted);
        }
Пример #25
0
        public async Task EditInvitation_AsPlanner_ShouldUpdateParticipant()
        {
            // Arrange
            var          participants = new List <CreateParticipantsDto>(_participants);
            const string email1       = "*****@*****.**";
            const string email2       = "*****@*****.**";

            participants.Add(
                new CreateParticipantsDto
            {
                Organization  = Organization.External,
                ExternalEmail = new CreateExternalEmailDto
                {
                    Email = email1
                },
                SortKey = 3
            });
            var(invitationId, editInvitationDto) = await CreateValidEditInvitationDtoAsync(participants);

            Assert.AreEqual(3, editInvitationDto.UpdatedParticipants.Count());

            var editParticipants = editInvitationDto.UpdatedParticipants.ElementAt(2);

            Assert.AreEqual(email1, editParticipants.ExternalEmail.Email);
            editParticipants.ExternalEmail.Email = email2;

            // Act
            await InvitationsControllerTestsHelper.EditInvitationAsync(
                UserType.Planner,
                TestFactory.PlantWithAccess,
                invitationId,
                editInvitationDto);

            // Assert
            var updatedInvitation = await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                invitationId);

            Assert.AreEqual(_mcPkgScope.Count, updatedInvitation.McPkgScope.Count());
            Assert.AreEqual(3, updatedInvitation.Participants.Count());
            Assert.AreEqual(email2, updatedInvitation.Participants.ElementAt(2).ExternalEmail.ExternalEmail);
        }
Пример #26
0
        public async Task GetAttachment_AsViewer_ShouldGetAttachment()
        {
            // Arrange
            var invitationAttachments = await InvitationsControllerTestsHelper.GetAttachmentsAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                InitialMdpInvitationId);

            Assert.AreNotEqual(invitationAttachments.Count, 0);

            // Act
            var attachmentDto = await InvitationsControllerTestsHelper.GetAttachmentAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                InitialMdpInvitationId,
                invitationAttachments.First().Id);

            // Assert
            Assert.AreEqual(invitationAttachments.First().Id, attachmentDto.Id);
        }
Пример #27
0
        internal async Task <(int, CompletePunchOutDto)> CreateValidCompletePunchOutDtoAsync(List <CreateParticipantsDto> participants)
        {
            var id = await InvitationsControllerTestsHelper.CreateInvitationAsync(
                UserType.Planner,
                TestFactory.PlantWithAccess,
                Guid.NewGuid().ToString(),
                Guid.NewGuid().ToString(),
                InvitationLocation,
                DisciplineType.DP,
                _invitationStartTime,
                _invitationEndTime,
                participants,
                _mcPkgScope,
                null);

            var invitation = await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                id);

            var completerParticipant = invitation.Participants
                                       .Single(p => p.Organization == Organization.Contractor);

            var completePunchOutDto = new CompletePunchOutDto
            {
                InvitationRowVersion  = invitation.RowVersion,
                ParticipantRowVersion = completerParticipant.RowVersion,
                Participants          = new List <ParticipantToChangeDto>
                {
                    new ParticipantToChangeDto
                    {
                        Id         = completerParticipant.Id,
                        Note       = $"Some note about the punch round or attendee {Guid.NewGuid():B}",
                        RowVersion = completerParticipant.RowVersion,
                        Attended   = true
                    }
                }
            };

            return(id, completePunchOutDto);
        }
Пример #28
0
        public async Task CancelPunchOut_AsCreator_ShouldCancelPunchOut()
        {
            // Arrange
            var(invitationToCancelId, cancelPunchOutDto) = await CreateValidCancelPunchOutDtoAsync(_participantsForSigning, UserType.Creator);

            // Act
            var newRowVersion = await InvitationsControllerTestsHelper.CancelPunchOutAsync(
                UserType.Creator,
                TestFactory.PlantWithAccess,
                invitationToCancelId,
                cancelPunchOutDto);

            // Assert
            var canceledInvitation = await InvitationsControllerTestsHelper.GetInvitationAsync(
                UserType.Creator,
                TestFactory.PlantWithAccess,
                invitationToCancelId);

            Assert.AreEqual(IpoStatus.Canceled, canceledInvitation.Status);
            AssertRowVersionChange(cancelPunchOutDto.RowVersion, newRowVersion);
        }
Пример #29
0
        public async Task DeleteAttachment_AsPlanner_ShouldDeleteAttachment()
        {
            // Arrange
            var attachment = await UploadAttachmentAsync(InitialMdpInvitationId);

            // Act
            await InvitationsControllerTestsHelper.DeleteAttachmentAsync(
                UserType.Planner,
                TestFactory.PlantWithAccess,
                InitialMdpInvitationId,
                attachment.Id,
                attachment.RowVersion);

            // Assert
            var attachmentDtos = await InvitationsControllerTestsHelper.GetAttachmentsAsync(
                UserType.Viewer,
                TestFactory.PlantWithAccess,
                InitialMdpInvitationId);

            Assert.IsNull(attachmentDtos.SingleOrDefault(m => m.Id == attachment.Id));
        }
Пример #30
0
        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);
        }