public async Task Handler_ShouldReturnWithCanEditAttendedStatusAndNotesForSignerWhenNotSigned() { var newCurrentUserOid = new Guid("11111111-2222-2222-2222-333333333332"); var currentUserProviderMock = new Mock <ICurrentUserProvider>(); currentUserProviderMock.Setup(x => x.GetCurrentUserOid()).Returns(newCurrentUserOid); using (var context = new IPOContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var functionalRoleDetails = new ProCoSysFunctionalRole { Code = _functionalRoleCode2, Description = "FR description", Email = "*****@*****.**", InformationEmail = null, Persons = new List <ProCoSysPerson> { new ProCoSysPerson { AzureOid = newCurrentUserOid.ToString(), Email = "*****@*****.**", FirstName = "FN", LastName = "LN", UserName = "******" } }, UsePersonalEmail = true }; IList <ProCoSysFunctionalRole> frDetails = new List <ProCoSysFunctionalRole> { functionalRoleDetails }; _functionalRoleApiServiceMock .Setup(x => x.GetFunctionalRolesByCodeAsync(_plantProvider.Plant, new List <string> { _functionalRoleCode2 })) .Returns(Task.FromResult(frDetails)); var query = new GetInvitationByIdQuery(_mdpInvitationId); var dut = new GetInvitationByIdQueryHandler( context, _meetingClientMock.Object, currentUserProviderMock.Object, _functionalRoleApiServiceMock.Object, _plantProvider, _loggerMock.Object); var result = await dut.Handle(query, default); Assert.IsNotNull(result); Assert.AreEqual(ResultType.Ok, result.ResultType); var invitationDto = result.Data; Assert.IsFalse(invitationDto.Participants.First().CanEditAttendedStatusAndNote); Assert.IsFalse(invitationDto.Participants.ToList()[1].CanEditAttendedStatusAndNote); Assert.IsTrue(invitationDto.Participants.ToList()[2].CanEditAttendedStatusAndNote); } }
private void AssertFunctionalRoleData(ProCoSysFunctionalRole pcsFunctionalRole, ProCoSysFunctionalRoleDto functionalRoleDto) { Assert.AreEqual(pcsFunctionalRole.Code, functionalRoleDto.Code); Assert.AreEqual(pcsFunctionalRole.Description, functionalRoleDto.Description); Assert.AreEqual(pcsFunctionalRole.Email, functionalRoleDto.Email); Assert.AreEqual(pcsFunctionalRole.InformationEmail, functionalRoleDto.InformationEmail); Assert.AreEqual(pcsFunctionalRole.Persons, functionalRoleDto.Persons); }
public async Task Handler_ShouldReturnIpo_IfPersonsInFunctionalRoleHaveAzureOidNull() { using var context = new IPOContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider); { var functionalRoleDetails = new ProCoSysFunctionalRole { Code = _functionalRoleCode1, Description = "FR description", Email = "*****@*****.**", InformationEmail = null, Persons = new List <ProCoSysPerson> { new ProCoSysPerson { AzureOid = null, Email = "*****@*****.**", FirstName = "FN", LastName = "LN", UserName = "******" } }, UsePersonalEmail = true }; IList <ProCoSysFunctionalRole> frDetails = new List <ProCoSysFunctionalRole> { functionalRoleDetails }; _functionalRoleApiServiceMock .Setup(x => x.GetFunctionalRolesByCodeAsync(_plantProvider.Plant, new List <string> { _functionalRoleCode1 })) .Returns(Task.FromResult(frDetails)); var query = new GetInvitationByIdQuery(_mdpInvitationId); var dut = new GetInvitationByIdQueryHandler( context, _meetingClientMock.Object, _currentUserProvider, _functionalRoleApiServiceMock.Object, _plantProvider, _loggerMock.Object); var result = await dut.Handle(query, default); Assert.IsNotNull(result); Assert.AreEqual(ResultType.Ok, result.ResultType); var invitationDto = result.Data; AssertInvitation(invitationDto, _mdpInvitation); } }
public void Setup() { _mainApiOptions = new Mock <IOptionsMonitor <LibraryApiOptions> >(); _mainApiOptions .Setup(x => x.CurrentValue) .Returns(new LibraryApiOptions { BaseAddress = "http://example.com" }); _foreignApiClient = new Mock <IBearerTokenApiClient>(); _proCoSysFunctionalRole1 = new ProCoSysFunctionalRole { Code = "A", Description = "Description1", Email = "*****@*****.**", InformationEmail = "*****@*****.**", UsePersonalEmail = true, Persons = new List <ProCoSysPerson> { new ProCoSysPerson { AzureOid = new Guid("11111111-1111-2222-2222-333333333333").ToString(), Email = "*****@*****.**", FirstName = "Ola", LastName = "Nordmann", UserName = "******" } } }; _proCoSysFunctionalRole2 = new ProCoSysFunctionalRole { Code = "B", Description = "Description2", Email = "*****@*****.**", InformationEmail = "*****@*****.**", UsePersonalEmail = false }; _extraHeaders = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("x-plant", _plant) }; _foreignApiClient .SetupSequence(x => x.QueryAndDeserializeAsync <List <ProCoSysFunctionalRole> >(It.IsAny <string>(), _extraHeaders)) .Returns(Task.FromResult(new List <ProCoSysFunctionalRole> { _proCoSysFunctionalRole1, _proCoSysFunctionalRole2 })); _dut = new LibraryApiFunctionalRoleService(_foreignApiClient.Object, _mainApiOptions.Object); }
public void Setup() { _plantProviderMock = new Mock <IPlantProvider>(); _plantProviderMock .Setup(x => x.Plant) .Returns(_plant); _currentUserProviderMock = new Mock <ICurrentUserProvider>(); _personRepositoryMock = new Mock <IPersonRepository>(); _meetingClientMock = new Mock <IFusionMeetingClient>(); _meetingClientMock .Setup(x => x.CreateMeetingAsync(It.IsAny <Action <GeneralMeetingBuilder> >())) .Returns(Task.FromResult( new GeneralMeeting( new ApiGeneralMeeting() { Classification = string.Empty, Contract = null, Convention = string.Empty, DateCreatedUtc = DateTime.MinValue, DateEnd = new ApiDateTimeTimeZoneModel(), DateStart = new ApiDateTimeTimeZoneModel(), ExternalId = null, Id = _meetingId, InviteBodyHtml = string.Empty, IsDisabled = false, IsOnlineMeeting = false, Location = string.Empty, Organizer = new ApiPersonDetailsV1(), OutlookMode = string.Empty, Participants = new List <ApiMeetingParticipant>(), Project = null, ResponsiblePersons = new List <ApiPersonDetailsV1>(), Series = null, Title = string.Empty }))); _invitationRepositoryMock = new Mock <IInvitationRepository>(); _invitationRepositoryMock .Setup(x => x.Add(It.IsAny <Invitation>())) .Callback <Invitation>(x => _createdInvitation = x); _transactionMock = new Mock <IDbContextTransaction>(); _unitOfWorkMock = new Mock <IUnitOfWork>(); _unitOfWorkMock.Setup(x => x.BeginTransaction(It.IsAny <CancellationToken>())) .Returns(Task.FromResult(_transactionMock.Object)); _commPkgApiServiceMock = new Mock <ICommPkgApiService>(); _mcPkgDetails1 = new ProCoSysMcPkg { CommPkgNo = _commPkgNo, Description = "D1", Id = 1, McPkgNo = _mcPkgNo1, System = _system }; _mcPkgDetails2 = new ProCoSysMcPkg { CommPkgNo = _commPkgNo, Description = "D2", Id = 2, McPkgNo = _mcPkgNo2, System = _system }; IList <ProCoSysMcPkg> mcPkgDetails = new List <ProCoSysMcPkg> { _mcPkgDetails1, _mcPkgDetails2 }; _mcPkgApiServiceMock = new Mock <IMcPkgApiService>(); _mcPkgApiServiceMock .Setup(x => x.GetMcPkgsByMcPkgNosAsync(_plant, _projectName, _mcPkgScope)) .Returns(Task.FromResult(mcPkgDetails)); _personDetails = new ProCoSysPerson { AzureOid = _azureOid.ToString(), FirstName = "Ola", LastName = "Nordman", Email = "*****@*****.**" }; _personApiServiceMock = new Mock <IPersonApiService>(); _personApiServiceMock .Setup(x => x.GetPersonByOidWithPrivilegesAsync(_plant, _azureOid.ToString(), "IPO", new List <string> { "SIGN" })) .Returns(Task.FromResult(_personDetails)); _functionalRoleDetails = new ProCoSysFunctionalRole { Code = _functionalRoleCode, Description = "FR description", Email = "*****@*****.**", InformationEmail = null, Persons = null, UsePersonalEmail = false }; _functionalRoleWithMultipleEmailsDetails = new ProCoSysFunctionalRole { Code = _functionalRoleWithMultipleEmailsCode, Description = "FR description", Email = "[email protected];[email protected]", InformationEmail = null, Persons = null, UsePersonalEmail = false }; _functionalRoleWithMultipleInformationEmailsDetails = new ProCoSysFunctionalRole { Code = _functionalRoleWithMultipleInformationEmailsCode, Description = "FR description", Email = "*****@*****.**", InformationEmail = "[email protected];[email protected]", Persons = null, UsePersonalEmail = false }; IList <ProCoSysFunctionalRole> frDetails = new List <ProCoSysFunctionalRole> { _functionalRoleDetails }; IList <ProCoSysFunctionalRole> frMultipleEmailsDetails = new List <ProCoSysFunctionalRole> { _functionalRoleWithMultipleEmailsDetails }; IList <ProCoSysFunctionalRole> frMultipleInformationDetails = new List <ProCoSysFunctionalRole> { _functionalRoleWithMultipleInformationEmailsDetails }; _functionalRoleApiServiceMock = new Mock <IFunctionalRoleApiService>(); _functionalRoleApiServiceMock .Setup(x => x.GetFunctionalRolesByCodeAsync(_plant, new List <string> { _functionalRoleCode })) .Returns(Task.FromResult(frDetails)); _functionalRoleApiServiceMock .Setup(x => x.GetFunctionalRolesByCodeAsync(_plant, new List <string> { _functionalRoleWithMultipleEmailsCode })) .Returns(Task.FromResult(frMultipleEmailsDetails)); _functionalRoleApiServiceMock .Setup(x => x.GetFunctionalRolesByCodeAsync(_plant, new List <string> { _functionalRoleWithMultipleInformationEmailsCode })) .Returns(Task.FromResult(frMultipleInformationDetails)); _meetingOptionsMock = new Mock <IOptionsMonitor <MeetingOptions> >(); _command = new CreateInvitationCommand( _title, _description, _location, new DateTime(2020, 9, 1, 12, 0, 0, DateTimeKind.Utc), new DateTime(2020, 9, 1, 13, 0, 0, DateTimeKind.Utc), _projectName, _type, _participants, _mcPkgScope, null); _dut = new CreateInvitationCommandHandler( _plantProviderMock.Object, _meetingClientMock.Object, _invitationRepositoryMock.Object, _unitOfWorkMock.Object, _commPkgApiServiceMock.Object, _mcPkgApiServiceMock.Object, _personApiServiceMock.Object, _functionalRoleApiServiceMock.Object, _meetingOptionsMock.Object, _personRepositoryMock.Object, _currentUserProviderMock.Object, new Mock <ILogger <CreateInvitationCommandHandler> >().Object); }
public void Setup() { _plantProviderMock = new Mock <IPlantProvider>(); _plantProviderMock .Setup(x => x.Plant) .Returns(_plant); _personRepositoryMock = new Mock <IPersonRepository>(); _meetingClientMock = new Mock <IFusionMeetingClient>(); _meetingClientMock .Setup(x => x.UpdateMeetingAsync(_meetingId, It.IsAny <Action <GeneralMeetingPatcher> >())) .Returns(Task.FromResult( new GeneralMeeting( new ApiGeneralMeeting { Classification = string.Empty, Contract = null, Convention = string.Empty, DateCreatedUtc = DateTime.MinValue, DateEnd = new ApiDateTimeTimeZoneModel(), DateStart = new ApiDateTimeTimeZoneModel(), ExternalId = null, Id = _meetingId, InviteBodyHtml = string.Empty, IsDisabled = false, IsOnlineMeeting = false, Location = string.Empty, Organizer = new ApiPersonDetailsV1(), OutlookMode = string.Empty, Participants = new List <ApiMeetingParticipant>(), Project = null, ResponsiblePersons = new List <ApiPersonDetailsV1>(), Series = null, Title = string.Empty }))); _unitOfWorkMock = new Mock <IUnitOfWork>(); //mock comm pkg response from main API var commPkgDetails = new ProCoSysCommPkg { CommPkgNo = _commPkgNo, Description = "D1", Id = 1, CommStatus = "OK", System = _system }; IList <ProCoSysCommPkg> pcsCommPkgDetails = new List <ProCoSysCommPkg> { commPkgDetails }; _commPkgApiServiceMock = new Mock <ICommPkgApiService>(); _commPkgApiServiceMock .Setup(x => x.GetCommPkgsByCommPkgNosAsync(_plant, _projectName, _commPkgScope)) .Returns(Task.FromResult(pcsCommPkgDetails)); //mock mc pkg response from main API var mcPkgDetails1 = new ProCoSysMcPkg { CommPkgNo = _commPkgNo, Description = "D1", Id = 1, McPkgNo = _mcPkgNo1, System = _system }; var mcPkgDetails2 = new ProCoSysMcPkg { CommPkgNo = _commPkgNo2, Description = "D2", Id = 2, McPkgNo = _mcPkgNo2, System = _system }; IList <ProCoSysMcPkg> mcPkgDetails = new List <ProCoSysMcPkg> { mcPkgDetails1, mcPkgDetails2 }; _mcPkgApiServiceMock = new Mock <IMcPkgApiService>(); _mcPkgApiServiceMock .Setup(x => x.GetMcPkgsByMcPkgNosAsync(_plant, _projectName, _mcPkgScope)) .Returns(Task.FromResult(mcPkgDetails)); //mock person response from main API var personDetails = new ProCoSysPerson { AzureOid = _azureOid.ToString(), FirstName = _firstName, LastName = _lastName, Email = "*****@*****.**", UserName = "******" }; var newPersonDetails = new ProCoSysPerson { AzureOid = _newAzureOid.ToString(), FirstName = "Kari", LastName = "Nordman", Email = "*****@*****.**", UserName = "******" }; _personApiServiceMock = new Mock <IPersonApiService>(); _personApiServiceMock .Setup(x => x.GetPersonByOidWithPrivilegesAsync(_plant, _azureOid.ToString(), "IPO", new List <string> { "SIGN" })) .Returns(Task.FromResult(personDetails)); _personApiServiceMock .Setup(x => x.GetPersonByOidWithPrivilegesAsync(_plant, _newAzureOid.ToString(), "IPO", new List <string> { "SIGN" })) .Returns(Task.FromResult(newPersonDetails)); //mock functional role response from main API var frDetails = new ProCoSysFunctionalRole { Code = _functionalRoleCode, Description = "FR description", Email = "*****@*****.**", InformationEmail = null, Persons = null, UsePersonalEmail = false }; var newFrDetails = new ProCoSysFunctionalRole { Code = _newFunctionalRoleCode, Description = "FR description2", Email = "*****@*****.**", InformationEmail = null, Persons = null, UsePersonalEmail = false }; var frMultipleEmailsDetails = new ProCoSysFunctionalRole { Code = _functionalRoleWithMultipleEmailsCode, Description = "FR description", Email = "[email protected];[email protected]", InformationEmail = null, Persons = null, UsePersonalEmail = false }; var frMultipleInformationEmailsDetails = new ProCoSysFunctionalRole { Code = _functionalRoleWithMultipleInformationEmailsCode, Description = "FR description", Email = "*****@*****.**", InformationEmail = "[email protected];[email protected]", Persons = null, UsePersonalEmail = false }; IList <ProCoSysFunctionalRole> pcsFrDetails = new List <ProCoSysFunctionalRole> { frDetails }; IList <ProCoSysFunctionalRole> newPcsFrDetails = new List <ProCoSysFunctionalRole> { newFrDetails }; IList <ProCoSysFunctionalRole> pcsFrMultipleEmailsDetails = new List <ProCoSysFunctionalRole> { frMultipleEmailsDetails }; IList <ProCoSysFunctionalRole> pcsFrMultipleInformationEmailsDetails = new List <ProCoSysFunctionalRole> { frMultipleInformationEmailsDetails }; _functionalRoleApiServiceMock = new Mock <IFunctionalRoleApiService>(); _functionalRoleApiServiceMock .Setup(x => x.GetFunctionalRolesByCodeAsync(_plant, new List <string> { _functionalRoleCode })) .Returns(Task.FromResult(pcsFrDetails)); _functionalRoleApiServiceMock .Setup(x => x.GetFunctionalRolesByCodeAsync(_plant, new List <string> { _newFunctionalRoleCode })) .Returns(Task.FromResult(newPcsFrDetails)); _functionalRoleApiServiceMock .Setup(x => x.GetFunctionalRolesByCodeAsync(_plant, new List <string> { _functionalRoleWithMultipleEmailsCode })) .Returns(Task.FromResult(pcsFrMultipleEmailsDetails)); _functionalRoleApiServiceMock .Setup(x => x.GetFunctionalRolesByCodeAsync(_plant, new List <string> { _functionalRoleWithMultipleInformationEmailsCode })) .Returns(Task.FromResult(pcsFrMultipleInformationEmailsDetails)); var mcPkgs = new List <McPkg> { new McPkg(_plant, _projectName, _commPkgNo, _mcPkgNo1, "d", _system), new McPkg(_plant, _projectName, _commPkgNo, _mcPkgNo2, "d2", _system) }; //create invitation _dpInvitation = new Invitation( _plant, _projectName, _title, _description, _typeDp, new DateTime(), new DateTime(), null, mcPkgs, null) { MeetingId = _meetingId }; var commPkgs = new List <CommPkg> { new CommPkg(_plant, _projectName, _commPkgNo, "d", "ok", _system), new CommPkg(_plant, _projectName, _commPkgNo, "d2", "ok", _system) }; //create invitation _mdpInvitation = new Invitation( _plant, _projectName, _title, _description, _typeMdp, new DateTime(), new DateTime(), null, new List <McPkg>(), commPkgs) { MeetingId = _meetingId }; _mdpInvitation.SetProtectedIdForTesting(_mdpInvitationId); var participant = new Participant( _plant, Organization.Contractor, IpoParticipantType.FunctionalRole, _functionalRoleCode, null, null, null, null, null, 0); participant.SetProtectedIdForTesting(_participantId); _dpInvitation.AddParticipant(participant); _dpInvitation.AddParticipant(new Participant( _plant, Organization.ConstructionCompany, IpoParticipantType.Person, null, _firstName, _lastName, null, "*****@*****.**", _azureOid, 1)); _dpInvitation.SetProtectedIdForTesting(_dpInvitationId); _invitationRepositoryMock = new Mock <IInvitationRepository>(); _invitationRepositoryMock .Setup(x => x.GetByIdAsync(_dpInvitationId)) .Returns(Task.FromResult(_dpInvitation)); _invitationRepositoryMock .Setup(x => x.GetByIdAsync(_mdpInvitationId)) .Returns(Task.FromResult(_mdpInvitation)); _meetingOptionsMock = new Mock <IOptionsMonitor <MeetingOptions> >(); _meetingOptionsMock.Setup(x => x.CurrentValue) .Returns(new MeetingOptions { PcsBaseUrl = _plant }); //command _command = new EditInvitationCommand( _dpInvitationId, _newTitle, _newDescription, null, new DateTime(2020, 9, 1, 12, 0, 0, DateTimeKind.Utc), new DateTime(2020, 9, 1, 13, 0, 0, DateTimeKind.Utc), _typeMdp, _updatedParticipants, null, _commPkgScope, _rowVersion); _dut = new EditInvitationCommandHandler( _invitationRepositoryMock.Object, _meetingClientMock.Object, _plantProviderMock.Object, _unitOfWorkMock.Object, _mcPkgApiServiceMock.Object, _commPkgApiServiceMock.Object, _personApiServiceMock.Object, _functionalRoleApiServiceMock.Object, _meetingOptionsMock.Object, _personRepositoryMock.Object); }
public async Task Handler_ShouldReturnWithCannotEditAttendedStatusAndNotesForContractorWhenCompleted() { var newCurrentUserOid = new Guid("11111111-2222-2222-2222-333333333339"); var currentUserProviderMock = new Mock <ICurrentUserProvider>(); currentUserProviderMock.Setup(x => x.GetCurrentUserOid()).Returns(newCurrentUserOid); using (var context = new IPOContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var person = context.QuerySet <Person>().FirstAsync().Result; var invitation = context.Invitations.Include(i => i.Participants).Single(inv => inv.Id == _mdpInvitationId); invitation.CompleteIpo( invitation.Participants.First(), invitation.Participants.First().RowVersion.ConvertToString(), person, DateTime.Now); context.SaveChangesAsync().Wait(); } using (var context = new IPOContext(_dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var functionalRoleDetails = new ProCoSysFunctionalRole { Code = _functionalRoleCode1, Description = "FR description", Email = "*****@*****.**", InformationEmail = null, Persons = new List <ProCoSysPerson> { new ProCoSysPerson { AzureOid = newCurrentUserOid.ToString(), Email = "*****@*****.**", FirstName = "FN", LastName = "LN", UserName = "******" } }, UsePersonalEmail = true }; IList <ProCoSysFunctionalRole> frDetails = new List <ProCoSysFunctionalRole> { functionalRoleDetails }; _functionalRoleApiServiceMock .Setup(x => x.GetFunctionalRolesByCodeAsync(_plantProvider.Plant, new List <string> { _functionalRoleCode1 })) .Returns(Task.FromResult(frDetails)); var query = new GetInvitationByIdQuery(_mdpInvitationId); var dut = new GetInvitationByIdQueryHandler( context, _meetingClientMock.Object, currentUserProviderMock.Object, _functionalRoleApiServiceMock.Object, _plantProvider, _loggerMock.Object); var result = await dut.Handle(query, default); Assert.IsNotNull(result); Assert.AreEqual(ResultType.Ok, result.ResultType); var invitationDto = result.Data; Assert.IsFalse(invitationDto.Participants.All(participant => participant.CanEditAttendedStatusAndNote)); Assert.IsFalse(invitationDto.CanDelete); Assert.IsTrue(invitationDto.CanCancel); } }
protected override void SetupNewDatabase(DbContextOptions <IPOContext> dbContextOptions) { using (var context = new IPOContext(dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { const string projectName = "Project1"; const string description = "Description"; const string commPkgNo = "CommPkgNo"; const string mcPkgNo = "McPkgNo"; const string system = "1|2"; var functionalRoleParticipant = new Participant( TestPlant, Organization.Contractor, IpoParticipantType.FunctionalRole, _functionalRoleCode1, null, null, null, _frEmail1, null, 0); var personParticipant = new Participant( TestPlant, Organization.ConstructionCompany, IpoParticipantType.Person, null, "FirstName", "LastName", "UN", _personEmail1, _currentUserOid, 1); var functionalRoleParticipant2 = new Participant( TestPlant, Organization.Commissioning, IpoParticipantType.FunctionalRole, _functionalRoleCode2, null, null, null, null, null, 2); var frPerson1 = new Participant( TestPlant, Organization.Commissioning, IpoParticipantType.Person, _functionalRoleCode2, "FirstName2", "LastName2", "UN2", _frPersonEmail1, new Guid("11111111-2222-2222-2222-333333333332"), 2); var frPerson2 = new Participant( TestPlant, Organization.Commissioning, IpoParticipantType.Person, _functionalRoleCode2, "FirstName3", "LastName3", "UN3", _frPersonEmail2, new Guid("11111111-2222-2222-2222-333333333331"), 2); var commPkg = new CommPkg( TestPlant, projectName, commPkgNo, description, "OK", system); _mdpInvitation = new Invitation( TestPlant, projectName, "Title", "Description", DisciplineType.MDP, new DateTime(), new DateTime(), null, null, new List <CommPkg> { commPkg }) { MeetingId = _meetingId }; _mdpInvitation.AddParticipant(functionalRoleParticipant); _mdpInvitation.AddParticipant(personParticipant); _mdpInvitation.AddParticipant(functionalRoleParticipant2); _mdpInvitation.AddParticipant(frPerson1); _mdpInvitation.AddParticipant(frPerson2); var mcPkg = new McPkg( TestPlant, projectName, commPkgNo, mcPkgNo, description, system); _dpInvitation = new Invitation( TestPlant, projectName, "Title 2", "Description 2", DisciplineType.DP, new DateTime(), new DateTime(), null, new List <McPkg> { mcPkg }, null) { MeetingId = _meetingId }; var functionalRoleParticipantForDp = new Participant( TestPlant, Organization.Contractor, IpoParticipantType.FunctionalRole, _functionalRoleCode1, null, null, null, _frEmail1, null, 0); var personParticipantForDp = new Participant( TestPlant, Organization.ConstructionCompany, IpoParticipantType.Person, null, "FirstName", "LastName", "UN", _personEmail1, _currentUserOid, 1); _dpInvitation.AddParticipant(functionalRoleParticipantForDp); _dpInvitation.AddParticipant(personParticipantForDp); var functionalRoleDetails = new ProCoSysFunctionalRole { Code = _functionalRoleCode1, Description = "FR description", Email = _frEmail1, InformationEmail = null, Persons = null, UsePersonalEmail = false }; var functionalRoleDetails2 = new ProCoSysFunctionalRole { Code = _functionalRoleCode2, Description = "FR description", Email = null, InformationEmail = null, Persons = new List <ProCoSysPerson> { new ProCoSysPerson { AzureOid = "11111111-2222-2222-2222-333333333332", Email = _frPersonEmail1, FirstName = null, LastName = null, UserName = null }, new ProCoSysPerson { AzureOid = "11111111-2222-2222-2222-333333333331", Email = _frPersonEmail2, FirstName = null, LastName = null, UserName = null } }, UsePersonalEmail = true }; IList <ProCoSysFunctionalRole> frDetails = new List <ProCoSysFunctionalRole> { functionalRoleDetails }; IList <ProCoSysFunctionalRole> frDetails2 = new List <ProCoSysFunctionalRole> { functionalRoleDetails2 }; _functionalRoleApiServiceMock = new Mock <IFunctionalRoleApiService>(); _functionalRoleApiServiceMock .Setup(x => x.GetFunctionalRolesByCodeAsync(_plantProvider.Plant, new List <string> { _functionalRoleCode1 })) .Returns(Task.FromResult(frDetails)); _functionalRoleApiServiceMock .Setup(x => x.GetFunctionalRolesByCodeAsync(_plantProvider.Plant, new List <string> { _functionalRoleCode2 })) .Returns(Task.FromResult(frDetails2)); _loggerMock = new Mock <ILogger <GetInvitationByIdQueryHandler> >(); _permissionCacheMock = new Mock <IPermissionCache>(); _meetingClientMock = new Mock <IFusionMeetingClient>(); _meetingClientMock .Setup(x => x.GetMeetingAsync(It.IsAny <Guid>(), It.IsAny <Action <ODataQuery> >())) .Returns(Task.FromResult( new GeneralMeeting( new ApiGeneralMeeting() { Classification = string.Empty, Contract = null, Convention = string.Empty, DateCreatedUtc = DateTime.MinValue, DateEnd = new ApiDateTimeTimeZoneModel(), DateStart = new ApiDateTimeTimeZoneModel(), ExternalId = null, Id = _meetingId, InviteBodyHtml = string.Empty, IsDisabled = false, IsOnlineMeeting = false, Location = string.Empty, Organizer = new ApiPersonDetailsV1(), OutlookMode = string.Empty, Participants = new List <ApiMeetingParticipant>() { new ApiMeetingParticipant() { Id = Guid.NewGuid(), Person = new ApiPersonDetailsV1() { Id = _currentUserOid, Mail = _personEmail1 }, OutlookResponse = "None" }, new ApiMeetingParticipant() { Id = Guid.NewGuid(), Person = new ApiPersonDetailsV1() { Id = Guid.NewGuid(), Mail = _frEmail1 }, OutlookResponse = "Declined" }, new ApiMeetingParticipant() { Id = Guid.NewGuid(), Person = new ApiPersonDetailsV1() { Id = Guid.NewGuid(), Mail = _frPersonEmail1 }, OutlookResponse = "Accepted" }, new ApiMeetingParticipant() { Id = Guid.NewGuid(), Person = new ApiPersonDetailsV1() { Id = Guid.NewGuid(), Mail = _frPersonEmail2 }, OutlookResponse = "Declined" } }, Project = null, ResponsiblePersons = new List <ApiPersonDetailsV1>(), Series = null, Title = string.Empty }))); context.Invitations.Add(_mdpInvitation); context.Invitations.Add(_dpInvitation); context.SaveChangesAsync().Wait(); _mdpInvitationId = _mdpInvitation.Id; _dpInvitationId = _dpInvitation.Id; } }