private static Comment SeedComment(IPOContext dbContext, Invitation invitation) { var comment = new Comment(invitation.Plant, "comment text"); invitation.AddComment(comment); dbContext.SaveChangesAsync().Wait(); return(comment); }
protected override void SetupNewDatabase(DbContextOptions <IPOContext> dbContextOptions) { using (var context = new IPOContext(dbContextOptions, _plantProvider, _eventDispatcher, _currentUserProvider)) { var invitation = new Invitation( TestPlant, "TestProject", "TestInvitation", "TestDescription", DisciplineType.DP, new DateTime(), new DateTime(), null, new List <McPkg> { new McPkg(TestPlant, "TestProject", "commno", "mcno", "d", "1|2") }, null); var comment = new Comment(TestPlant, "comment text"); invitation.AddComment(comment); context.Invitations.Add(invitation); context.SaveChangesAsync().Wait(); } }
public void Setup() { _mcPkg = new McPkg(TestPlant, _projectName2, _commPkgNo2, _mcPkgNo, "Description", _system); _mcPkg.SetProtectedIdForTesting(McPkgId); _commPkg = new CommPkg(TestPlant, _projectName, _commPkgNo, "Description", "OK", "1|2"); _commPkg.SetProtectedIdForTesting(CommPkgId); _commPkg2 = new CommPkg(TestPlant, _projectName, _commPkgNo2, "Description", "OK", "1|2"); _commPkg.SetProtectedIdForTesting(CommPkgId); _commPkg4 = new CommPkg(TestPlant, _projectName, _commPkgNo4, "Description", "OK", "1|2"); _commPkg4.SetProtectedIdForTesting(CommPkgId4); _mcPkg2 = new McPkg(TestPlant, _projectName, _commPkgNo, _mcPkgNo2, "Description", _system); _mcPkg2.SetProtectedIdForTesting(McPkgId2); _mcPkg3 = new McPkg(TestPlant, _projectName, _commPkgNo3, _mcPkgNo3, "Description", _system); _mcPkg3.SetProtectedIdForTesting(McPkgId3); _participant = new Participant( TestPlant, Organization.Contractor, IpoParticipantType.FunctionalRole, "FR", null, null, null, "*****@*****.**", null, 0); _participant.SetProtectedIdForTesting(ParticipantId); _dpInviation = new Invitation( TestPlant, _projectName2, "Title", "D", DisciplineType.DP, new DateTime(), new DateTime(), null, new List <McPkg> { _mcPkg }, null); _dpInviation.SetProtectedIdForTesting(InvitationWithMcPkgId); _dpInviationMove = new Invitation( TestPlant, _projectName, "Title", "D", DisciplineType.DP, new DateTime(), new DateTime(), null, new List <McPkg> { _mcPkg3 }, null); _dpInviationMove.SetProtectedIdForTesting(InvitationWithMcPkgMoveId); _mdpInvitation = new Invitation( TestPlant, _projectName, "Title 2", "D", DisciplineType.MDP, new DateTime(), new DateTime(), null, null, new List <CommPkg> { _commPkg }); _mdpInvitationWithTwoCommpkgs = new Invitation( TestPlant, _projectName, "Title 3", "D", DisciplineType.MDP, new DateTime(), new DateTime(), null, null, new List <CommPkg> { _commPkg, _commPkg2 }); _attachment = new Attachment(TestPlant, "filename.txt"); _dpInviation.AddParticipant(_participant); _dpInviation.AddAttachment(_attachment); _comment = new Comment(TestPlant, "comment"); _mdpInvitation.AddComment(_comment); _mdpInvitation4 = new Invitation( TestPlant, _projectName, "Title 4", "D", DisciplineType.MDP, new DateTime(), new DateTime(), null, null, new List <CommPkg> { _commPkg4 }); _invitations = new List <Invitation> { _dpInviation, _dpInviationMove, _mdpInvitation, _mdpInvitationWithTwoCommpkgs, _mdpInvitation4 }; _dbInvitationSetMock = _invitations.AsQueryable().BuildMockDbSet(); ContextHelper .ContextMock .Setup(x => x.Invitations) .Returns(_dbInvitationSetMock.Object); var attachments = new List <Attachment> { _attachment }; _attachmentSetMock = attachments.AsQueryable().BuildMockDbSet(); ContextHelper .ContextMock .Setup(x => x.Attachments) .Returns(_attachmentSetMock.Object); var participants = new List <Participant> { _participant }; _participantSetMock = participants.AsQueryable().BuildMockDbSet(); ContextHelper .ContextMock .Setup(x => x.Participants) .Returns(_participantSetMock.Object); var mcPkgs = new List <McPkg> { _mcPkg, _mcPkg2, _mcPkg3 }; _mcPkgSetMock = mcPkgs.AsQueryable().BuildMockDbSet(); ContextHelper .ContextMock .Setup(x => x.McPkgs) .Returns(_mcPkgSetMock.Object); var commPkgs = new List <CommPkg> { _commPkg, _commPkg2, _commPkg4 }; _commPkgSetMock = commPkgs.AsQueryable().BuildMockDbSet(); ContextHelper .ContextMock .Setup(x => x.CommPkgs) .Returns(_commPkgSetMock.Object); var comments = new List <Comment> { _comment }; _commentSetMock = comments.AsQueryable().BuildMockDbSet(); ContextHelper .ContextMock .Setup(x => x.Comments) .Returns(_commentSetMock.Object); _dut = new InvitationRepository(ContextHelper.ContextMock.Object); }