public async Task ThenIAmAbleToGetAnAccountByTheInternalId()
        {
            //Arrange
            var accountId       = 1923701937;
            var hashedAccountId = "ABC123";

            HashingService.Setup(x => x.HashValue(accountId)).Returns(hashedAccountId);
            ApiService.Setup(x => x.GetAccount(hashedAccountId, It.IsAny <CancellationToken>())).ReturnsAsync(new AccountDetailViewModel {
                AccountId = accountId, ApprenticeshipEmployerType = ApprenticeshipEmployerType.Levy.ToString(), LegalEntities = new ResourceList(new List <ResourceViewModel>()), PayeSchemes = new ResourceList(new List <ResourceViewModel>())
            });
            Mediator.Setup(x => x.SendAsync(It.IsAny <GetAccountBalancesRequest>())).ReturnsAsync(new GetAccountBalancesResponse {
                Accounts = new List <AccountBalance> {
                    new AccountBalance()
                }
            });
            Mediator.Setup(x => x.SendAsync(It.IsAny <GetTransferAllowanceQuery>())).ReturnsAsync(new GetTransferAllowanceResponse {
                TransferAllowance = new TransferAllowance()
            });

            //Act
            var response = await Controller.GetAccount(accountId);

            //Assert
            Assert.IsNotNull(response);
            Assert.IsInstanceOf <OkNegotiatedContentResult <AccountDetailViewModel> >(response);
        }
        public AuthorizationContextProviderTestsFixture SetInvalidAccountId()
        {
            AccountHashedId = "AAA";

            var routeData = new RouteData();

            routeData.Values[RouteValueKeys.AccountHashedId] = AccountHashedId;

            HttpContext.Setup(c => c.Request.RequestContext.RouteData).Returns(routeData);
            HashingService.Setup(h => h.DecodeValue(AccountHashedId)).Throws <Exception>();

            return(this);
        }
Esempio n. 3
0
        public AuthorizationContextProviderTestsFixture SetInvalidAccountId()
        {
            AccountHashedId = "AAA";

            var routeData = new RouteData();
            var accountId = 0L;

            routeData.Values[RouteValueKeys.AccountHashedId] = AccountHashedId;

            RoutingFeature.Setup(f => f.RouteData).Returns(routeData);
            HashingService.Setup(h => h.TryDecodeLong(AccountHashedId, out accountId)).Returns(false);

            return(this);
        }
        public async Task ThenACombinedAgreementIsCreated()
        {
            var accountId = 12345;

            HashingService.Setup(x => x.DecodeValue(Command.HashedAccountId)).Returns(accountId);
            EmployerAgreementRepository.Setup(x => x.GetAccountAgreements(accountId)).ReturnsAsync(
                new List <EmployerAgreement>
            {
                new EmployerAgreement {
                    Template = new AgreementTemplate {
                        AgreementType = AgreementType.Levy
                    }
                }
            });

            await CommandHandler.Handle(Command);

            AccountRepository.Verify(x =>
                                     x.CreateLegalEntityWithAgreement(It.Is <CreateLegalEntityWithAgreementParams>(y =>
                                                                                                                   y.AgreementType == AgreementType.Combined)));
        }
Esempio n. 5
0
        public async Task ThenIAmAbleToGetAnAccountByTheInternalId()
        {
            //Arrange
            var accountId       = 1923701937;
            var hashedAccountId = "ABC123";
            var accountResponse = new GetEmployerAccountByHashedIdResponse {
                Account = new AccountDetail()
            };

            HashingService.Setup(x => x.HashValue(accountId)).Returns(hashedAccountId);
            Mediator.Setup(x => x.SendAsync(It.Is <GetEmployerAccountByHashedIdQuery>(q => q.HashedAccountId == hashedAccountId))).ReturnsAsync(accountResponse);
            Mediator.Setup(x => x.SendAsync(It.IsAny <GetTransferAllowanceQuery>())).ReturnsAsync(new GetTransferAllowanceResponse {
                TransferAllowance = new TransferAllowance()
            });

            //Act
            var response = await Controller.GetAccount(accountId);

            //Assert
            Assert.IsNotNull(response);
            Assert.IsInstanceOf <OkNegotiatedContentResult <AccountDetailViewModel> >(response);
        }
        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);
        }