Ejemplo n.º 1
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.º 2
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.º 3
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.º 4
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);
        }