Esempio n. 1
0
        public async Task TestInitializeAsync()
        {
            _sigurdSigner    = TestFactory.Instance.GetTestUserForUserType(UserType.Signer).Profile;
            _pernillaPlanner = TestFactory.Instance.GetTestUserForUserType(UserType.Planner).Profile;
            _contractor      = TestFactory.Instance.GetTestUserForUserType(UserType.Contractor).Profile;
            _andreaAdmin     = TestFactory.Instance.GetTestUserForUserType(UserType.Admin).Profile;

            var personParticipant = new CreateInvitedPersonDto
            {
                AzureOid = Guid.NewGuid(),
                Email    = "*****@*****.**",
                Required = true
            };
            var person1InFunctionalRoleParticipant = new CreateInvitedPersonDto
            {
                AzureOid = new Guid(_contractor.Oid),
                Email    = "*****@*****.**"
            };
            var person2InFunctionalRoleParticipant = new CreateInvitedPersonDto
            {
                AzureOid = Guid.NewGuid(),
                Email    = "på[email protected]"
            };
            var functionalRoleParticipant = new CreateFunctionalRoleDto
            {
                Code    = FunctionalRoleCode,
                Persons = new List <CreateInvitedPersonDto>
                {
                    person1InFunctionalRoleParticipant,
                    person2InFunctionalRoleParticipant
                }
            };

            _participants = new List <CreateParticipantsDto>
            {
                new CreateParticipantsDto
                {
                    Organization   = Organization.Contractor,
                    FunctionalRole = functionalRoleParticipant,
                    SortKey        = 0
                },
                new CreateParticipantsDto
                {
                    Organization = Organization.ConstructionCompany,
                    Person       = personParticipant,
                    SortKey      = 1
                }
            };

            _participantsForSigning = new List <CreateParticipantsDto>
            {
                new CreateParticipantsDto
                {
                    Organization = Organization.Contractor,
                    Person       = _sigurdSigner.AsCreatePersonDto(true),
                    SortKey      = 0
                },
                new CreateParticipantsDto
                {
                    Organization = Organization.ConstructionCompany,
                    Person       = _sigurdSigner.AsCreatePersonDto(true),
                    SortKey      = 1
                },
                new CreateParticipantsDto
                {
                    Organization = Organization.TechnicalIntegrity,
                    Person       = _sigurdSigner.AsCreatePersonDto(false),
                    SortKey      = 2
                }
            };

            var knownGeneralMeeting = new ApiGeneralMeeting
            {
                Classification = string.Empty,
                Contract       = null,
                Convention     = string.Empty,
                DateCreatedUtc = DateTime.MinValue,
                DateEnd        = new ApiDateTimeTimeZoneModel
                {
                    DateTimeUtc = _invitationEndTime
                },
                DateStart = new ApiDateTimeTimeZoneModel
                {
                    DateTimeUtc = _invitationStartTime
                },
                ExternalId      = null,
                Id              = KnownTestData.MeetingId,
                InviteBodyHtml  = string.Empty,
                IsDisabled      = false,
                IsOnlineMeeting = false,
                Location        = InvitationLocation,
                Organizer       = new ApiPersonDetailsV1(),
                OutlookMode     = string.Empty,
                Participants    = new List <ApiMeetingParticipant>
                {
                    new ApiMeetingParticipant
                    {
                        Id     = Guid.NewGuid(),
                        Person = new ApiPersonDetailsV1 {
                            Id = Guid.NewGuid(), Mail = "*****@*****.**"
                        },
                        OutlookResponse = "Required"
                    },
                    new ApiMeetingParticipant
                    {
                        Id     = Guid.NewGuid(),
                        Person = new ApiPersonDetailsV1 {
                            Id = Guid.NewGuid(), Mail = "*****@*****.**"
                        },
                        OutlookResponse = "Accepted"
                    }
                },
                Project            = null,
                ResponsiblePersons = new List <ApiPersonDetailsV1>(),
                Series             = null,
                Title = string.Empty
            };

            _commentId = TestFactory.Instance.KnownTestData.CommentIds.First();

            const string McPkgNo1 = "MC1";
            const string McPkgNo2 = "MC2";

            _mcPkgScope = new List <string> {
                McPkgNo1, McPkgNo2
            };

            _mcPkgDetails1 = new ProCoSysMcPkg
            {
                CommPkgNo = KnownTestData.CommPkgNo, Description = "D1", Id = 1, McPkgNo = McPkgNo1, System = KnownTestData.System
            };
            _mcPkgDetails2 = new ProCoSysMcPkg
            {
                CommPkgNo = KnownTestData.CommPkgNo, Description = "D2", Id = 2, McPkgNo = McPkgNo2, System = KnownTestData.System
            };
            IList <ProCoSysMcPkg> mcPkgDetails = new List <ProCoSysMcPkg> {
                _mcPkgDetails1, _mcPkgDetails2
            };

            TestFactory.Instance
            .McPkgApiServiceMock
            .Setup(x => x.GetMcPkgsByMcPkgNosAsync(TestFactory.PlantWithAccess, TestFactory.ProjectWithAccess,
                                                   _mcPkgScope))
            .Returns(Task.FromResult(mcPkgDetails));

            var personsInFunctionalRole = new List <ProCoSysPerson>
            {
                new ProCoSysPerson
                {
                    AzureOid  = person1InFunctionalRoleParticipant.AzureOid.ToString(),
                    FirstName = "Per",
                    LastName  = "Persen",
                    Email     = person1InFunctionalRoleParticipant.Email,
                    UserName  = "******"
                },
                new ProCoSysPerson
                {
                    AzureOid  = person2InFunctionalRoleParticipant.AzureOid.ToString(),
                    FirstName = "Pål",
                    LastName  = "Persen",
                    Email     = person2InFunctionalRoleParticipant.Email,
                    UserName  = "******"
                }
            };

            IList <ProCoSysFunctionalRole> pcsFunctionalRoles1 = new List <ProCoSysFunctionalRole>
            {
                new ProCoSysFunctionalRole
                {
                    Code             = KnownTestData.FunctionalRoleCode,
                    Description      = "Description",
                    Email            = "*****@*****.**",
                    InformationEmail = null,
                    Persons          = personsInFunctionalRole,
                    UsePersonalEmail = true
                }
            };

            IList <ProCoSysFunctionalRole> pcsFunctionalRoles2 = new List <ProCoSysFunctionalRole>
            {
                new ProCoSysFunctionalRole
                {
                    Code             = FunctionalRoleCode,
                    Description      = "Description",
                    Email            = "*****@*****.**",
                    InformationEmail = null,
                    Persons          = personsInFunctionalRole,
                    UsePersonalEmail = true
                }
            };

            TestFactory.Instance
            .FunctionalRoleApiServiceMock
            .Setup(x => x.GetFunctionalRolesByCodeAsync(TestFactory.PlantWithAccess,
                                                        new List <string> {
                KnownTestData.FunctionalRoleCode
            }))
            .Returns(Task.FromResult(pcsFunctionalRoles1));

            TestFactory.Instance
            .FunctionalRoleApiServiceMock
            .Setup(x => x.GetFunctionalRolesByCodeAsync(TestFactory.PlantWithAccess,
                                                        new List <string> {
                FunctionalRoleCode
            }))
            .Returns(Task.FromResult(pcsFunctionalRoles2));

            TestFactory.Instance
            .PersonApiServiceMock
            .Setup(x => x.GetPersonByOidWithPrivilegesAsync(
                       TestFactory.PlantWithAccess,
                       _sigurdSigner.Oid,
                       "IPO",
                       It.IsAny <List <string> >()))
            .Returns(Task.FromResult(_sigurdSigner.AsProCoSysPerson()));

            TestFactory.Instance
            .PersonApiServiceMock
            .Setup(x => x.GetPersonByOidWithPrivilegesAsync(
                       TestFactory.PlantWithAccess,
                       _contractor.Oid,
                       "IPO",
                       It.IsAny <List <string> >()))
            .Returns(Task.FromResult(_contractor.AsProCoSysPerson()));

            TestFactory.Instance
            .PersonApiServiceMock
            .Setup(x => x.GetPersonByOidWithPrivilegesAsync(
                       TestFactory.PlantWithAccess,
                       _pernillaPlanner.Oid,
                       "IPO",
                       It.IsAny <List <string> >()))
            .Returns(Task.FromResult(_pernillaPlanner.AsProCoSysPerson()));

            TestFactory.Instance
            .PersonApiServiceMock
            .Setup(x => x.GetPersonByOidWithPrivilegesAsync(
                       TestFactory.PlantWithAccess,
                       _andreaAdmin.Oid,
                       "IPO",
                       It.IsAny <List <string> >()))
            .Returns(Task.FromResult(_andreaAdmin.AsProCoSysPerson()));

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

            TestFactory.Instance
            .FusionMeetingClientMock
            .Setup(x => x.CreateMeetingAsync(It.IsAny <Action <GeneralMeetingBuilder> >()))
            .Returns(Task.FromResult(new GeneralMeeting(knownGeneralMeeting)));

            TestFactory.Instance
            .FusionMeetingClientMock
            .Setup(x => x.GetMeetingAsync(It.IsAny <Guid>(), It.IsAny <Action <ODataQuery> >()))
            .Returns(Task.FromResult(new GeneralMeeting(knownGeneralMeeting)));

            TestFactory.Instance
            .MeetingOptionsMock
            .Setup(x => x.CurrentValue)
            .Returns(new MeetingOptions {
                PcsBaseUrl = TestFactory.PlantWithAccess
            });
            _attachmentOnInitialMdpInvitation = await UploadAttachmentAsync(InitialMdpInvitationId);
        }
Esempio n. 2
0
        public void TestInitialize()
        {
            _sigurdSigner = TestFactory.Instance.GetTestUserForUserType(UserType.Signer).Profile;

            _participants = new List <CreateParticipantsDto>
            {
                new CreateParticipantsDto
                {
                    Organization = Organization.Contractor,
                    Person       = _sigurdSigner.AsCreatePersonDto(true),
                    SortKey      = 0
                },
                new CreateParticipantsDto
                {
                    Organization = Organization.ConstructionCompany,
                    Person       = _sigurdSigner.AsCreatePersonDto(true),
                    SortKey      = 1
                },
                new CreateParticipantsDto
                {
                    Organization = Organization.TechnicalIntegrity,
                    Person       = _sigurdSigner.AsCreatePersonDto(false),
                    SortKey      = 2
                }
            };

            const string McPkgNo = "MC1";

            _mcPkgScope = new List <string> {
                McPkgNo
            };

            _mcPkgDetails = new ProCoSysMcPkg
            {
                CommPkgNo   = KnownTestData.CommPkgNo,
                Description = "D1",
                Id          = 1,
                McPkgNo     = McPkgNo,
                System      = KnownTestData.System
            };

            IList <ProCoSysMcPkg> mcPkgDetails = new List <ProCoSysMcPkg> {
                _mcPkgDetails
            };

            _personsInFunctionalRole = new List <ProCoSysPerson>
            {
                new ProCoSysPerson
                {
                    AzureOid  = AzureOid,
                    FirstName = "FirstName",
                    LastName  = "LastName",
                    Email     = "*****@*****.**",
                    UserName  = "******"
                }
            };

            _pcsFunctionalRoles = new List <ProCoSysFunctionalRole>
            {
                new ProCoSysFunctionalRole
                {
                    Code             = FunctionalRoleCode,
                    Description      = "Description",
                    Email            = "*****@*****.**",
                    InformationEmail = null,
                    Persons          = _personsInFunctionalRole,
                    UsePersonalEmail = true
                }
            };

            var knownGeneralMeeting = new ApiGeneralMeeting
            {
                Classification = string.Empty,
                Contract       = null,
                Convention     = string.Empty,
                DateCreatedUtc = DateTime.MinValue,
                DateEnd        = new ApiDateTimeTimeZoneModel {
                    DateTimeUtc = _invitationEndTime
                },
                DateStart = new ApiDateTimeTimeZoneModel {
                    DateTimeUtc = _invitationStartTime
                },
                ExternalId      = null,
                Id              = KnownTestData.MeetingId,
                InviteBodyHtml  = string.Empty,
                IsDisabled      = false,
                IsOnlineMeeting = false,
                Location        = InvitationLocation,
                Organizer       = new ApiPersonDetailsV1(),
                OutlookMode     = string.Empty,
                Participants    = new List <ApiMeetingParticipant>
                {
                    new ApiMeetingParticipant
                    {
                        Id     = Guid.NewGuid(),
                        Person = new ApiPersonDetailsV1 {
                            Id = Guid.NewGuid(), Mail = "*****@*****.**"
                        },
                        OutlookResponse = "Required"
                    },
                    new ApiMeetingParticipant
                    {
                        Id     = Guid.NewGuid(),
                        Person = new ApiPersonDetailsV1 {
                            Id = Guid.NewGuid(), Mail = "*****@*****.**"
                        },
                        OutlookResponse = "Accepted"
                    }
                },
                Project            = null,
                ResponsiblePersons = new List <ApiPersonDetailsV1>(),
                Series             = null,
                Title = string.Empty
            };

            TestFactory.Instance
            .MeApiServiceMock
            .Setup(x => x.GetFunctionalRoleCodesAsync(
                       TestFactory.PlantWithAccess))
            .Returns(Task.FromResult(_functionalRoleCodes));

            TestFactory.Instance
            .McPkgApiServiceMock
            .Setup(x => x.GetMcPkgsByMcPkgNosAsync(
                       TestFactory.PlantWithAccess,
                       TestFactory.ProjectWithAccess,
                       _mcPkgScope))
            .Returns(Task.FromResult(mcPkgDetails));

            TestFactory.Instance
            .FunctionalRoleApiServiceMock
            .Setup(x => x.GetFunctionalRolesByCodeAsync(TestFactory.PlantWithAccess,
                                                        new List <string> {
                FunctionalRoleCode
            }))
            .Returns(Task.FromResult(_pcsFunctionalRoles));

            TestFactory.Instance
            .PersonApiServiceMock
            .Setup(x => x.GetPersonByOidWithPrivilegesAsync(
                       TestFactory.PlantWithAccess,
                       _sigurdSigner.Oid,
                       "IPO",
                       It.IsAny <List <string> >()))
            .Returns(Task.FromResult(_sigurdSigner.AsProCoSysPerson()));

            TestFactory.Instance
            .FusionMeetingClientMock
            .Setup(x => x.CreateMeetingAsync(It.IsAny <Action <GeneralMeetingBuilder> >()))
            .Returns(Task.FromResult(new GeneralMeeting(knownGeneralMeeting)));

            TestFactory.Instance
            .EmailServiceMock
            .Setup(x => x.SendEmailsAsync(It.IsAny <List <string> >(), It.IsAny <string>(), It.IsAny <string>(),
                                          It.IsAny <CancellationToken>()))
            .Returns(Task.CompletedTask);

            TestFactory.Instance
            .MeetingOptionsMock
            .Setup(x => x.CurrentValue)
            .Returns(new MeetingOptions {
                PcsBaseUrl = TestFactory.PlantWithAccess
            });
        }