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 attachmentA = new Attachment(TestPlant, "fileA.txt");
                var attachmentB = new Attachment(TestPlant, "fileB.txt");
                invitation.AddAttachment(attachmentA);
                invitation.AddAttachment(attachmentB);
                context.Invitations.Add(invitation);
                context.SaveChangesAsync().Wait();
            }

            var blobStorageOptions = new BlobStorageOptions();

            _blobStorageOptionsMonitorMock = new Mock <IOptionsMonitor <BlobStorageOptions> >();
            _blobStorageOptionsMonitorMock
            .Setup(x => x.CurrentValue)
            .Returns(blobStorageOptions);
        }
        public void Setup()
        {
            _invitation = new Invitation(
                _plant,
                _projectName,
                "TestInvitation",
                "Description",
                DisciplineType.DP,
                new DateTime(),
                new DateTime(),
                null,
                new List <McPkg> {
                new McPkg(_plant, _projectName, "Comm", "Mc", "d", "1|2")
            },
                null);
            _attachment = new Attachment(_plant, "ExistingFile.txt");
            _attachment.SetProtectedIdForTesting(2);
            _invitation.AddAttachment(_attachment);

            _invitationRepositoryMock = new Mock <IInvitationRepository>();
            _invitationRepositoryMock
            .Setup(x => x.GetByIdAsync(1))
            .Returns(Task.FromResult(_invitation));

            _unitOfWorkMock = new Mock <IUnitOfWork>();

            _blobStorageMock = new Mock <IBlobStorage>();
            var blobStorageOptions = new BlobStorageOptions()
            {
                BlobContainer = "TestContainer"
            };

            _monitorMock = Mock.Of <IOptionsMonitor <BlobStorageOptions> >(x => x.CurrentValue == blobStorageOptions);

            _command = new DeleteAttachmentCommand(1, 2, "AAAAAAAAAAA=");

            _dut = new DeleteAttachmentCommandHandler(
                _invitationRepositoryMock.Object,
                _unitOfWorkMock.Object,
                _blobStorageMock.Object,
                _monitorMock);
        }
        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);
        }