示例#1
0
        public void Arrange()
        {
            base.SetUp();

            _employerAgreementRepository = new Mock <IEmployerAgreementRepository>();
            _hashingService = new Mock <IHashingService>();
            _agreement      = new EmployerAgreementView()
            {
                AgreementType = AgreementType.NonLevyExpressionOfInterest
            };

            RequestHandler = new GetEmployerAgreementByIdRequestHandler(
                _employerAgreementRepository.Object,
                _hashingService.Object,
                RequestValidator.Object);

            Query = new GetEmployerAgreementByIdRequest
            {
                HashedAgreementId = "ABC123",
            };

            _employerAgreementRepository.Setup(x => x.GetEmployerAgreement(It.IsAny <long>()))
            .ReturnsAsync(_agreement);

            _hashingService.Setup(x => x.DecodeValue(It.IsAny <string>()))
            .Returns(AgreementId);
        }
示例#2
0
        private async Task PublihAgreementSignedMessage(EmployerAgreementView agreement, MembershipView owner, string correlationId)
        {
            var commitments = await _commitmentService.GetEmployerCommitments(agreement.AccountId);

            var accountHasCommitments = commitments?.Any() ?? false;

            await PublishAgreementSignedMessage(agreement.AccountId, agreement.AccountLegalEntityId, agreement.LegalEntityId, agreement.LegalEntityName,
                                                agreement.Id, accountHasCommitments, owner.FullName(), owner.UserRef, agreement.AgreementType,
                                                agreement.VersionNumber, correlationId);
        }
        public async Task ThenTheAgreementDataIsRetrievedAndSaved()
        {
            var expectedAgreement     = new EmployerAgreementView();
            var employerAgreementHref = $"/api/accounts/ABC123/agreements/ZZZZ999";

            _accountGateway.Setup(x => x.GetEmployerAgreement(employerAgreementHref)).ReturnsAsync(expectedAgreement);

            await _commandHandler.Handle(new CreateEmployerAgreementCommand { AgreementHref = employerAgreementHref });

            _employerAgreementRepository.Verify(x => x.SaveEmployerAgreement(expectedAgreement), Times.Once);
        }
        public override void HttpClientSetup()
        {
            _uri = $"/api/accounts/{HashedAccountId}/legalEntities/{HashedlegalEntityId}/agreements/{HashedAgreementId}/agreement";
            var absoluteUri = Configuration.ApiBaseUrl.TrimEnd('/') + _uri;

            var agreement = new EmployerAgreementView {
                HashedAccountId = HashedAccountId
            };

            HttpClient.Setup(c => c.GetAsync(absoluteUri)).Returns(Task.FromResult(JsonConvert.SerializeObject(agreement)));
        }
示例#5
0
        public void Arrange()
        {
            _accountRepository    = new Mock <IAccountRepository>();
            _membershipRepository = new Mock <IMembershipRepository>();
            _mediator             = new Mock <IMediator>();

            _owner = new MembershipView
            {
                AccountId = 1234,
                UserId    = 9876,
                Email     = "*****@*****.**",
                FirstName = "Bob",
                LastName  = "Green"
            };

            _agreementView = new EmployerAgreementView
            {
                AccountId                = _owner.AccountId,
                SignedDate               = DateTime.Now,
                SignedByName             = $"{_owner.FirstName} {_owner.LastName}",
                LegalEntityId            = 5246,
                LegalEntityName          = "Test Corp",
                LegalEntityCode          = "3476782638",
                LegalEntityAddress       = "12, test street",
                LegalEntityInceptionDate = DateTime.Now
            };

            _command = new CreateLegalEntityCommand
            {
                HashedAccountId = "ABC123",
                LegalEntity     = new LegalEntity(),
                SignAgreement   = true,
                SignedDate      = DateTime.Now.AddDays(-10),
                ExternalUserId  = "12345"
            };

            _membershipRepository.Setup(x => x.GetCaller(_command.HashedAccountId, _command.ExternalUserId))
            .ReturnsAsync(_owner);

            _accountRepository.Setup(x => x.CreateLegalEntity(_owner.AccountId, _command.LegalEntity))
            .ReturnsAsync(_agreementView);

            _genericEventFactory     = new Mock <IGenericEventFactory>();
            _legalEntityEventFactory = new Mock <ILegalEntityEventFactory>();

            _commandHandler = new CreateLegalEntityCommandHandler(
                _accountRepository.Object,
                _membershipRepository.Object,
                _mediator.Object,
                _genericEventFactory.Object,
                _legalEntityEventFactory.Object);
        }
示例#6
0
        public async Task ThenTheAgreementIsReturned()
        {
            var expectedAgreement = new EmployerAgreementView();

            var agreementHref = $"/api/accounts/2385/agreements/123456";

            AccountApiClient.Setup(x => x.GetResource <EmployerAgreementView>(agreementHref)).ReturnsAsync(expectedAgreement);

            var result = await AccountGateway.GetEmployerAgreement(agreementHref);

            result.Should().Be(expectedAgreement);
            AccountApiClient.Verify(x => x.GetResource <EmployerAgreementView>(agreementHref), Times.Once);
        }
示例#7
0
        private async Task ValidateLegalEntityHasNoCommitments(EmployerAgreementView agreement, long accountId, ValidationResult validationResult)
        {
            var commitments = await _employerCommitmentApi.GetEmployerAccountSummary(accountId);

            var commitment = commitments.FirstOrDefault(c =>
                                                        !string.IsNullOrEmpty(c.LegalEntityIdentifier) &&
                                                        c.LegalEntityIdentifier.Equals(agreement.LegalEntityCode) &&
                                                        c.LegalEntityOrganisationType == agreement.LegalEntitySource);

            if (commitment != null && (commitment.ActiveCount + commitment.PausedCount + commitment.PendingApprovalCount) != 0)
            {
                validationResult.AddError(nameof(agreement.HashedAgreementId), "Agreement has already been signed and has active commitments");
                throw new InvalidRequestException(validationResult.ValidationDictionary);
            }
        }
        public void Arrange()
        {
            _mediator  = new Mock <IMediator>();
            _mapper    = ConfigureMapper();
            _agreement = new EmployerAgreementView();

            var response = new GetEmployerAgreementByIdResponse()
            {
                EmployerAgreement = _agreement
            };

            _orchestrator = new AgreementOrchestrator(_mediator.Object, _mapper);

            _mediator.Setup(x => x.SendAsync(It.IsAny <GetEmployerAgreementByIdRequest>()))
            .ReturnsAsync(response);
        }
示例#9
0
        public async Task SaveEmployerAgreement(EmployerAgreementView employerAgreement)
        {
            await WithConnection(async c =>
            {
                var parameters = new DynamicParameters();
                parameters.Add("@DasAccountId", employerAgreement.HashedAccountId, DbType.String);
                parameters.Add("@Status", employerAgreement.Status.ToString(), DbType.String);
                parameters.Add("@SignedBy", employerAgreement.SignedByName, DbType.String);
                parameters.Add("@SignedDate", employerAgreement.SignedDate, DbType.DateTime);
                parameters.Add("@ExpiredDate", employerAgreement.ExpiredDate, DbType.DateTime);
                parameters.Add("@DasLegalEntityId", employerAgreement.LegalEntityId, DbType.Int64);
                parameters.Add("@DasAgreementId", employerAgreement.HashedAgreementId, DbType.String);

                return(await c.ExecuteAsync(
                           sql: "[Data_Load].[SaveEmployerAgreement]",
                           param: parameters,
                           commandType: CommandType.StoredProcedure));
            });
        }
        public override void Arrange()
        {
            base.Arrange();

            _owner = new MembershipView
            {
                AccountId = 1234,
                UserId    = 9876,
                Email     = "*****@*****.**",
                FirstName = "Bob",
                LastName  = "Green",
                UserRef   = Guid.Parse(Command.ExternalUserId),
                Role      = Role.Owner,
            };

            _agreementView = new EmployerAgreementView
            {
                Id                       = 123,
                AccountId                = _owner.AccountId,
                SignedDate               = DateTime.Now,
                SignedByName             = $"{_owner.FirstName} {_owner.LastName}",
                LegalEntityId            = 5246,
                LegalEntityName          = "Test Corp",
                LegalEntityCode          = "3476782638",
                LegalEntitySource        = OrganisationType.CompaniesHouse,
                LegalEntityAddress       = "123 test street",
                LegalEntityInceptionDate = DateTime.Now,
                AccountLegalEntityId     = 830
            };

            MembershipRepository.Setup(x => x.GetCaller(Command.HashedAccountId, Command.ExternalUserId)).ReturnsAsync(_owner);

            AccountRepository.Setup(x => x.CreateLegalEntityWithAgreement(It.Is <CreateLegalEntityWithAgreementParams>(createParams => createParams.AccountId == _owner.AccountId))).ReturnsAsync(_agreementView);

            HashingService.Setup(hs => hs.HashValue(It.IsAny <long>())).Returns <long>(value => $"*{value}*");
            HashingService.Setup(hs => hs.DecodeValue(Command.HashedAccountId)).Returns(_owner.AccountId);

            AccountLegalEntityPublicHashingService.Setup(x => x.HashValue(_agreementView.AccountLegalEntityId)).Returns(ExpectedAccountLegalEntityPublicHashString);
        }
示例#11
0
        public void Arrange()
        {
            _accountRepository    = new Mock <IAccountRepository>();
            _membershipRepository = new Mock <IMembershipRepository>();
            _mediator             = new Mock <IMediator>();

            _owner = new MembershipView
            {
                AccountId = 1234,
                UserId    = 9876,
                Email     = "*****@*****.**",
                FirstName = "Bob",
                LastName  = "Green",
                UserRef   = Guid.NewGuid().ToString(),
                Role      = Role.Owner,
            };

            _agreementView = new EmployerAgreementView
            {
                Id                       = 123,
                AccountId                = _owner.AccountId,
                SignedDate               = DateTime.Now,
                SignedByName             = $"{_owner.FirstName} {_owner.LastName}",
                LegalEntityId            = 5246,
                LegalEntityName          = "Test Corp",
                LegalEntityCode          = "3476782638",
                LegalEntitySource        = OrganisationType.CompaniesHouse,
                LegalEntityAddress       = "123 test street",
                LegalEntityInceptionDate = DateTime.Now,
                AccountLegalEntityId     = 830
            };

            _command = new CreateLegalEntityCommand
            {
                HashedAccountId = "ABC123",
                SignAgreement   = true,
                SignedDate      = DateTime.Now.AddDays(-10),
                ExternalUserId  = _owner.UserRef,
                Name            = "Org Ltd",
                Code            = "3476782638",
                Source          = OrganisationType.CompaniesHouse,
                Address         = "123 test street"
            };

            _membershipRepository.Setup(x => x.GetCaller(_command.HashedAccountId, _command.ExternalUserId))
            .ReturnsAsync(_owner);

            _accountRepository
            .Setup(x => x.CreateLegalEntityWithAgreement(It.Is <CreateLegalEntityWithAgreementParams>(
                                                             createParams => createParams.AccountId == _owner.AccountId)))
            .ReturnsAsync(_agreementView);

            _genericEventFactory     = new Mock <IGenericEventFactory>();
            _legalEntityEventFactory = new Mock <ILegalEntityEventFactory>();
            _eventPublisher          = new Mock <IEventPublisher>();
            _agreementService        = new Mock <IAgreementService>();

            _hashingService = new Mock <IHashingService>();
            _hashingService.Setup(hs => hs.HashValue(It.IsAny <long>())).Returns <long>(value => $"*{value}*");
            _hashingService.Setup(hs => hs.DecodeValue(_command.HashedAccountId)).Returns(_owner.AccountId);

            _accountLegalEntityPublicHashingService = new Mock <IAccountLegalEntityPublicHashingService>();
            _accountLegalEntityPublicHashingService.Setup(x => x.HashValue(_agreementView.AccountLegalEntityId)).Returns(ExpectedAccountLegalEntityPublicHashString);

            _employerAgreementRepository = new Mock <IEmployerAgreementRepository>();

            _validator = new Mock <IValidator <CreateLegalEntityCommand> >();

            _validator.Setup(x => x.ValidateAsync(It.IsAny <CreateLegalEntityCommand>()))
            .ReturnsAsync(new ValidationResult()
            {
                IsUnauthorized = false
            });

            _commandHandler = new CreateLegalEntityCommandHandler(
                _accountRepository.Object,
                _membershipRepository.Object,
                _mediator.Object,
                _genericEventFactory.Object,
                _legalEntityEventFactory.Object,
                _eventPublisher.Object,
                _hashingService.Object,
                _accountLegalEntityPublicHashingService.Object,
                _agreementService.Object,
                _employerAgreementRepository.Object,
                _validator.Object
                );
        }
        private async Task CreateAuditEntries(MembershipView owner, EmployerAgreementView agreementView)
        {
            await _mediator.SendAsync(new CreateAuditCommand
            {
                EasAuditMessage = new EasAuditMessage
                {
                    Category          = "UPDATED",
                    Description       = $"User {owner.Email} added legal entity {agreementView.LegalEntityId} to account {owner.AccountId}",
                    ChangedProperties = new List <PropertyUpdate>
                    {
                        new PropertyUpdate {
                            PropertyName = "AccountId", NewValue = agreementView.AccountId.ToString()
                        },
                        new PropertyUpdate {
                            PropertyName = "Id", NewValue = agreementView.LegalEntityId.ToString()
                        },
                        new PropertyUpdate {
                            PropertyName = "Name", NewValue = agreementView.LegalEntityName
                        },
                        new PropertyUpdate {
                            PropertyName = "Code", NewValue = agreementView.LegalEntityCode
                        },
                        new PropertyUpdate {
                            PropertyName = "Status", NewValue = agreementView.LegalEntityStatus
                        },
                        new PropertyUpdate {
                            PropertyName = "Address", NewValue = agreementView.LegalEntityAddress
                        },
                        new PropertyUpdate {
                            PropertyName = "DateOfInception", NewValue = agreementView.LegalEntityInceptionDate.GetDateString("G")
                        },
                    },
                    RelatedEntities = new List <Entity> {
                        new Entity {
                            Id = agreementView.AccountId.ToString(), Type = "Account"
                        }
                    },
                    AffectedEntity = new Entity {
                        Type = "LegalEntity", Id = agreementView.LegalEntityId.ToString()
                    }
                }
            });

            await _mediator.SendAsync(new CreateAuditCommand
            {
                EasAuditMessage = new EasAuditMessage
                {
                    Category          = "UPDATED",
                    Description       = $"User {owner.Email} added signed agreement {agreementView.Id} to account {owner.AccountId}",
                    ChangedProperties = new List <PropertyUpdate>
                    {
                        new PropertyUpdate {
                            PropertyName = "AccountId", NewValue = agreementView.AccountId.ToString()
                        },
                        new PropertyUpdate {
                            PropertyName = "SignedDate", NewValue = agreementView.SignedDate.GetDateString("G")
                        },
                        new PropertyUpdate {
                            PropertyName = "SignedBy", NewValue = $"{owner.FirstName} {owner.LastName}"
                        }
                    },
                    RelatedEntities = new List <Entity> {
                        new Entity {
                            Id = agreementView.AccountId.ToString(), Type = "Account"
                        }
                    },
                    AffectedEntity = new Entity {
                        Type = "EmployerAgreement", Id = agreementView.Id.ToString()
                    }
                }
            });
        }
        public void Setup()
        {
            _command = new SignEmployerAgreementCommand
            {
                HashedAccountId   = "1AVCFD",
                HashedAgreementId = "2EQWE34",
                ExternalUserId    = Guid.NewGuid().ToString(),
                SignedDate        = DateTime.Now
            };

            _membershipRepository = new Mock <IMembershipRepository>();

            _hashingService = new Mock <IHashingService>();
            _hashingService.Setup(x => x.DecodeValue(_command.HashedAccountId)).Returns(AccountId);
            _hashingService.Setup(x => x.DecodeValue(_command.HashedAgreementId)).Returns(AgreementId);
            _hashingService.Setup(x => x.HashValue(It.IsAny <long>())).Returns(HashedLegalEntityId);

            _validator = new Mock <IValidator <SignEmployerAgreementCommand> >();
            _validator.Setup(x => x.ValidateAsync(It.IsAny <SignEmployerAgreementCommand>())).ReturnsAsync(new ValidationResult {
                ValidationDictionary = new Dictionary <string, string>()
            });


            _agreement = new EmployerAgreementView
            {
                HashedAgreementId    = "124GHJG",
                LegalEntityId        = LegalEntityId,
                LegalEntityName      = OrganisationName,
                AgreementType        = AgreementType,
                AccountId            = AccountId,
                AccountLegalEntityId = AccountLegalEntityId,
                Id = AgreementId
            };

            _agreementRepository = new Mock <IEmployerAgreementRepository>();

            _agreementRepository.Setup(x => x.GetEmployerAgreement(It.IsAny <long>()))
            .ReturnsAsync(_agreement);

            _agreementEventFactory = new Mock <IEmployerAgreementEventFactory>();

            _agreementEvent = new AgreementSignedEvent();

            _agreementEventFactory.Setup(
                x => x.CreateSignedEvent(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .Returns(_agreementEvent);

            _genericEventFactory = new Mock <IGenericEventFactory>();
            _mediator            = new Mock <IMediator>();

            _mediator.Setup(x => x.SendAsync(It.Is <GetUserByRefQuery>(s => s.UserRef == _command.ExternalUserId))).ReturnsAsync(new GetUserByRefResponse {
                User = new User {
                    CorrelationId = "CORRELATION_ID"
                }
            });

            _commintmentService = new Mock <ICommitmentService>();

            _commintmentService.Setup(x => x.GetEmployerCommitments(It.IsAny <long>()))
            .ReturnsAsync(new List <Cohort>());

            _eventPublisher = new TestableEventPublisher();

            _handler = new SignEmployerAgreementCommandHandler(
                _membershipRepository.Object,
                _agreementRepository.Object,
                _hashingService.Object,
                _validator.Object,
                _agreementEventFactory.Object,
                _genericEventFactory.Object,
                _mediator.Object,
                _eventPublisher,
                _commintmentService.Object);

            _owner = new MembershipView
            {
                UserId    = 1,
                Role      = Role.Owner,
                FirstName = "Fred",
                LastName  = "Bloggs",
                UserRef   = Guid.NewGuid()
            };

            _membershipRepository.Setup(x => x.GetCaller(_command.HashedAccountId, _command.ExternalUserId))
            .ReturnsAsync(_owner);
        }
示例#14
0
        public void Arrange()
        {
            _validator = new Mock <IValidator <RemoveLegalEntityCommand> >();
            _validator.Setup(x => x.ValidateAsync(It.IsAny <RemoveLegalEntityCommand>())).ReturnsAsync(new ValidationResult());

            _logger = new Mock <ILog>();

            _mediator = new Mock <IMediator>();

            _repository = new Mock <IEmployerAgreementRepository>();
            _repository.Setup(r => r.GetAccountLegalEntityAgreements(ExpectedAccountLegalEntityId))
            .ReturnsAsync(new List <EmployerAgreement>
            {
                new EmployerAgreement
                {
                    AccountLegalEntityId = ExpectedAccountLegalEntityId,
                    TemplateId           = 1,
                    Id         = ExpectedEmployerAgreementId,
                    SignedDate = DateTime.Now
                }
            });

            _expectedAgreement = new EmployerAgreementView
            {
                AccountLegalEntityId = ExpectedAccountLegalEntityId,
                LegalEntityId        = ExpectedLegalEntityId,
                LegalEntityName      = ExpectedLegalEntityName,
                Status          = EmployerAgreementStatus.Signed,
                LegalEntityCode = "test_code"
            };

            _repository.Setup(r => r.GetEmployerAgreement(ExpectedEmployerAgreementId)).ReturnsAsync(_expectedAgreement);

            _hashingService = new Mock <IHashingService>();
            _hashingService.Setup(x => x.DecodeValue(ExpectedHashedAccountId)).Returns(ExpectedAccountId);
            _hashingService.Setup(x => x.DecodeValue(ExpectedHashedEmployerAgreementId)).Returns(ExpectedEmployerAgreementId);
            _hashingService.Setup(x => x.HashValue(ExpectedEmployerAgreementId)).Returns(ExpectedHashedEmployerAgreementId);

            _accountLegalEntityPublicHashingService = new Mock <IAccountLegalEntityPublicHashingService>();
            _accountLegalEntityPublicHashingService.Setup(x => x.DecodeValue(ExpectedHashedAccountLegalEntityId)).Returns(ExpectedAccountLegalEntityId);

            _employerAgreementEventFactory = new Mock <IEmployerAgreementEventFactory>();
            _employerAgreementEventFactory.Setup(x => x.RemoveAgreementEvent(ExpectedHashedEmployerAgreementId)).Returns(new AgreementRemovedEvent {
                HashedAgreementId = ExpectedHashedEmployerAgreementId
            });
            _genericEventHandler = new Mock <IGenericEventFactory>();
            _genericEventHandler.Setup(x => x.Create(It.Is <AgreementRemovedEvent>(c => c.HashedAgreementId.Equals(ExpectedHashedEmployerAgreementId)))).Returns(new GenericEvent {
                Payload = ExpectedHashedEmployerAgreementId
            });

            _membershipRepository = new Mock <IMembershipRepository>();
            _membershipRepository
            .Setup(mr => mr.GetCaller(ExpectedAccountId, _expectedUserId))
            .Returns <long, string>((accountId, userRef) => Task.FromResult(new MembershipView {
                AccountId = ExpectedAccountId, FirstName = "Harry", LastName = "Potter"
            }));

            _eventPublisher = new Mock <IEventPublisher>();

            _commitmentsApi = new Mock <IEmployerCommitmentApi>();
            _commitmentsApi
            .Setup(x => x.GetEmployerAccountSummary(ExpectedAccountId))
            .ReturnsAsync(new List <ApprenticeshipStatusSummary>
            {
                new ApprenticeshipStatusSummary
                {
                    ActiveCount = 0, PausedCount = 0, PendingApprovalCount = 0, LegalEntityIdentifier = _expectedAgreement.LegalEntityCode
                }
            });

            _command = new RemoveLegalEntityCommand {
                HashedAccountId = ExpectedHashedAccountId, UserId = _expectedUserId, HashedAccountLegalEntityId = ExpectedHashedAccountLegalEntityId
            };

            _handler = new RemoveLegalEntityCommandHandler(
                _validator.Object,
                _logger.Object,
                _repository.Object,
                _mediator.Object,
                _accountLegalEntityPublicHashingService.Object,
                _hashingService.Object,
                _genericEventHandler.Object,
                _employerAgreementEventFactory.Object,
                _membershipRepository.Object,
                _eventPublisher.Object,
                _commitmentsApi.Object);
        }
示例#15
0
 private async Task PublishEvents(SignEmployerAgreementCommand message, string hashedLegalEntityId, EmployerAgreementView agreement, MembershipView owner, string correlationId)
 {
     await Task.WhenAll(
         PublishLegalGenericEvent(message, hashedLegalEntityId),
         PublihAgreementSignedMessage(agreement, owner, correlationId)
         );
 }
示例#16
0
        public void Setup()
        {
            _membershipRepository = new Mock <IMembershipRepository>();

            _hashingService = new Mock <IHashingService>();
            _hashingService.Setup(x => x.DecodeValue(It.IsAny <string>())).Returns(AgreementId);
            _hashingService.Setup(x => x.HashValue(It.IsAny <long>())).Returns(HashedLegalEntityId);

            _validator = new Mock <IValidator <SignEmployerAgreementCommand> >();
            _validator.Setup(x => x.ValidateAsync(It.IsAny <SignEmployerAgreementCommand>())).ReturnsAsync(new ValidationResult {
                ValidationDictionary = new Dictionary <string, string> ()
            });


            _agreement = new EmployerAgreementView
            {
                HashedAgreementId = "124GHJG",
                LegalEntityId     = 56465
            };

            _agreementRepository = new Mock <IEmployerAgreementRepository>();

            _agreementRepository.Setup(x => x.GetEmployerAgreement(It.IsAny <long>()))
            .ReturnsAsync(_agreement);

            _agreementEventFactory = new Mock <IEmployerAgreementEventFactory>();

            _agreementEvent = new AgreementSignedEvent();

            _agreementEventFactory.Setup(
                x => x.CreateSignedEvent(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>()))
            .Returns(_agreementEvent);

            _genericEventFactory = new Mock <IGenericEventFactory>();
            _mediator            = new Mock <IMediator>();

            _handler = new SignEmployerAgreementCommandHandler(
                _membershipRepository.Object,
                _agreementRepository.Object,
                _hashingService.Object,
                _validator.Object,
                _agreementEventFactory.Object,
                _genericEventFactory.Object,
                _mediator.Object);

            _command = new SignEmployerAgreementCommand
            {
                HashedAccountId   = "1AVCFD",
                HashedAgreementId = "2EQWE34",
                ExternalUserId    = Guid.NewGuid().ToString(),
                SignedDate        = DateTime.Now
            };

            _owner = new MembershipView
            {
                UserId    = 1,
                RoleId    = (short)Role.Owner,
                FirstName = "Fred",
                LastName  = "Bloggs"
            };

            _membershipRepository.Setup(x => x.GetCaller(_command.HashedAccountId, _command.ExternalUserId))
            .ReturnsAsync(_owner);
        }