public void Approve(Account.Account approverAccount, User approverUser)
        {
            RequiresApproverAccountIsTheReceiverAccount(approverAccount);
            RequiresTransferConnectionInvitationIsPending();

            var now = DateTime.UtcNow;

            Status = TransferConnectionInvitationStatus.Approved;

            Changes.Add(new TransferConnectionInvitationChange
            {
                Status      = Status,
                User        = approverUser,
                CreatedDate = now
            });

            Publish <ApprovedTransferConnectionRequestEvent>(e =>
            {
                e.ApprovedByUserId            = approverUser.Id;
                e.ApprovedByUserName          = approverUser.FullName;
                e.ApprovedByUserRef           = approverUser.Ref;
                e.Created                     = now;
                e.ReceiverAccountHashedId     = ReceiverAccount.HashedId;
                e.ReceiverAccountId           = ReceiverAccount.Id;
                e.ReceiverAccountName         = ReceiverAccount.Name;
                e.SenderAccountHashedId       = SenderAccount.HashedId;
                e.SenderAccountId             = SenderAccount.Id;
                e.SenderAccountName           = SenderAccount.Name;
                e.TransferConnectionRequestId = Id;
            });
        }
        public TransferConnectionInvitation(Account.Account senderAccount, Account.Account receiverAccount, User senderUser) : this()
        {
            var now = DateTime.UtcNow;

            SenderAccount   = senderAccount;
            ReceiverAccount = receiverAccount;
            Status          = TransferConnectionInvitationStatus.Pending;
            CreatedDate     = now;

            Changes.Add(new TransferConnectionInvitationChange
            {
                SenderAccount     = SenderAccount,
                ReceiverAccount   = ReceiverAccount,
                Status            = Status,
                DeletedBySender   = DeletedBySender,
                DeletedByReceiver = DeletedByReceiver,
                User        = senderUser,
                CreatedDate = now
            });

            Publish <SentTransferConnectionRequestEvent>(e =>
            {
                e.Created = now;
                e.ReceiverAccountHashedId     = ReceiverAccount.HashedId;
                e.ReceiverAccountId           = ReceiverAccount.Id;
                e.ReceiverAccountName         = ReceiverAccount.Name;
                e.SenderAccountHashedId       = SenderAccount.HashedId;
                e.SenderAccountId             = SenderAccount.Id;
                e.SenderAccountName           = SenderAccount.Name;
                e.SentByUserId                = senderUser.Id;
                e.SentByUserName              = senderUser.FullName;
                e.SentByUserRef               = senderUser.Ref;
                e.TransferConnectionRequestId = Id;
            });
        }
        public DeleteTransferConnectionInvitationTestFixture WithTransferConnection(
            TransferConnectionInvitationStatus status)
        {
            TransferConnectionInvitation = new TransferConnectionInvitationBuilder()
                                           .WithId(111111)
                                           .WithSenderAccount(SenderAccount)
                                           .WithReceiverAccount(ReceiverAccount)
                                           .WithStatus(status)
                                           .Build();

            TransferConnectionInvitationRepositoryMock
            .Setup(r => r.GetTransferConnectionInvitationById(TransferConnectionInvitation.Id))
            .ReturnsAsync(TransferConnectionInvitation);

            return(this);
        }
        public Task Handle(TransferConnectionInvitationStatus status, long deletingAccountId)
        {
            WithSenderAccount(TestSenderAccountId)
            .WithReceiverAccount(TestReceiverAccountId)
            .WithDeleterUser(TestUserId)
            .WithTransferConnection(status);

            var command = new DeleteTransferConnectionInvitationCommand
            {
                AccountId = deletingAccountId,
                UserRef   = DeleterUser.Ref,
                TransferConnectionInvitationId = TransferConnectionInvitation.Id
            };

            var handler = CreateHandler();

            return(handler.Handle(command));
        }
        public TransferConnectionInvitationBuilder WithStatus(TransferConnectionInvitationStatus status)
        {
            _transferConnectionInvitation.SetupProperty(i => i.Status, status);

            return(this);
        }
Ejemplo n.º 6
0
        public TransferConnectionInvitationTestsFixture AddInvitationFromSenderToReceiver(TransferConnectionInvitationStatus status)
        {
            SenderAccount.SentTransferConnectionInvitations.Add(
                new TransferConnectionInvitationBuilder()
                .WithReceiverAccount(ReceiverAccount)
                .WithStatus(status)
                .Build());

            return(this);
        }
 public void Handle_WhenDeleting_ThenShouldThrowExceptionIfNotRejected(long deletingAccountId, TransferConnectionInvitationStatus status)
 {
     Assert.ThrowsAsync <Exception>(() =>
                                    TestAsync(
                                        act: f => f.Handle(status, deletingAccountId),
                                        assert: null), "Requires transfer connection invitation is rejected.");
 }