Ejemplo n.º 1
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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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());
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);
        }
Ejemplo n.º 9
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);
        }
Ejemplo n.º 10
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);
        }
Ejemplo n.º 11
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);
        }
Ejemplo n.º 12
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);
        }
Ejemplo n.º 13
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);
        }
Ejemplo n.º 14
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);
        }
Ejemplo n.º 15
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());
        }
Ejemplo n.º 16
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);
        }
Ejemplo n.º 17
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);
        }
Ejemplo n.º 18
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);
        }
Ejemplo n.º 19
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);
        }
Ejemplo n.º 20
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);
        }
Ejemplo n.º 21
0
        internal async Task <(int, EditInvitedInvitationDto)> CreateValidEditInvitationDtoAsync(IList <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 editInvitationDto = new EditInvitedInvitationDto
            {
                Title               = invitation.Title,
                Description         = invitation.Description,
                StartTime           = invitation.StartTimeUtc,
                EndTime             = invitation.EndTimeUtc,
                Location            = invitation.Location,
                ProjectName         = invitation.ProjectName,
                RowVersion          = invitation.RowVersion,
                UpdatedParticipants = ConvertToParticipantDtoEdit(invitation.Participants),
                UpdatedCommPkgScope = null,
                UpdatedMcPkgScope   = _mcPkgScope
            };

            return(id, editInvitationDto);
        }
Ejemplo n.º 22
0
        public async Task CreateInvitation_AsPlanner_ShouldCreateInvitation()
        {
            const string Title       = "InvitationTitle";
            const string Description = "InvitationDescription";

            // Act
            var id = await InvitationsControllerTestsHelper.CreateInvitationAsync(
                UserType.Planner,
                TestFactory.PlantWithAccess,
                Title,
                Description,
                InvitationLocation,
                DisciplineType.DP,
                _invitationStartTime,
                _invitationEndTime,
                _participants,
                _mcPkgScope,
                null
                );

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

            Assert.IsTrue(id > 0);
            Assert.IsNotNull(invitation);
            Assert.AreEqual(Title, invitation.Title);
            Assert.AreEqual(Description, invitation.Description);
            Assert.AreEqual(InvitationLocation, invitation.Location);
            Assert.AreEqual(_mcPkgScope.Count, invitation.McPkgScope.Count());
            var originalParticipants = _participants;

            AssertParticipants(invitation, originalParticipants);
        }
Ejemplo n.º 23
0
        public async Task EditInvitation_AsPlanner_ShouldUpdateParticipantOrganization()
        {
            // Arrange
            var                participants = new List <CreateParticipantsDto>(_participants);
            const string       email1       = "*****@*****.**";
            const string       email2       = "*****@*****.**";
            const Organization org1         = Organization.External;
            const Organization org2         = Organization.TechnicalIntegrity;

            participants.Add(
                new CreateParticipantsDto
            {
                Organization  = org1,
                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);
            Assert.AreEqual(org1, editParticipants.Organization);

            editParticipants.Organization  = org2;
            editParticipants.ExternalEmail = null;
            var editInvitedPersonDto = new EditInvitedPersonDto
            {
                AzureOid = Guid.NewGuid(),
                Email    = email2
            };

            editParticipants.Person = editInvitedPersonDto;

            TestFactory.Instance
            .PersonApiServiceMock
            .Setup(x => x.GetPersonByOidWithPrivilegesAsync(
                       TestFactory.PlantWithAccess,
                       editInvitedPersonDto.AzureOid.ToString(),
                       "IPO",
                       new List <string> {
                "SIGN"
            }))
            .Returns(Task.FromResult(new ProCoSysPerson
            {
                AzureOid  = editInvitedPersonDto.AzureOid.ToString(),
                Email     = editInvitedPersonDto.Email,
                FirstName = "Ola",
                LastName  = "Nordmann",
                UserName  = "******"
            }));

            // 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(org2, updatedInvitation.Participants.ElementAt(2).Organization);
            Assert.IsNull(updatedInvitation.Participants.ElementAt(2).ExternalEmail);
            Assert.IsNotNull(updatedInvitation.Participants.ElementAt(2).Person);
            Assert.AreEqual(email2, updatedInvitation.Participants.ElementAt(2).Person.Email);
        }