public async Task ThenTheStatusShouldBeFound_ByHashedAccountId()
        {
            var callRequirements = new CallRequirements($"api/accounts/{_employerAccount.HashedAccountId}");

            // Act
            var account = await _tester.InvokeGetAsync <AccountDetailViewModel>(callRequirements);

            // Assert
            account.ExpectControllerType(typeof(EmployerAccountsController));
            account.ExpectStatusCodes(HttpStatusCode.OK);
            Assert.IsNotNull(account.Data);
        }
Exemplo n.º 2
0
        public async Task ThenTheStatusShouldBeNotFound_ById()
        {
            // Arrange
            var callRequirements = new CallRequirements($"api/accounts/internal/-1");

            // Act
            var response = await _tester.InvokeGetAsync <AccountDetailViewModel>(callRequirements);

            // Assert
            response.ExpectControllerType(typeof(EmployerAccountsController));
            response.ExpectStatusCodes(HttpStatusCode.NotFound);
            Assert.Pass("Verified we got http status NotFound");
        }
        public async Task ThenTheStatusShouldBeNotFound()
        {
            // Arrange
            var callRequirements =
                new CallRequirements("api/accounts/ZZZZZZ/legalentities");

            // Act
            var legalEntities = await _tester.InvokeGetAsync <ResourceList>(callRequirements);

            // Assert

            legalEntities.ExpectStatusCodes(HttpStatusCode.NotFound);
            legalEntities.ExpectControllerType(typeof(LegalEntitiesController));
            Assert.IsNull(legalEntities.Data);
        }
        public async Task ThenTheStatusShouldBeFound_AndDataShouldContainOnlyTheExpectedUser()
        {
            // Arrange
            string hashedAccountId = null;
            var    userRef         = Guid.Empty;

            await _tester.InitialiseData <EmployerAccountsDbBuilder>(async builder =>
            {
                var data = new TestModelBuilder()
                           .WithNewUser()
                           .WithNewAccount()
                           .WithNewLegalEntity();

                await builder.SetupDataAsync(data);

                hashedAccountId = data.CurrentAccount.AccountOutput.HashedAccountId;
                userRef         = data.CurrentUser.UserOutput.UserRef;
            });

            var callRequirements = new CallRequirements($"api/accounts/{hashedAccountId}/users");

            // Act
            var account = await _tester.InvokeGetAsync <ICollection <TeamMemberViewModel> >(callRequirements);

            // Assert

            account.ExpectControllerType(typeof(EmployerAccountsController));
            account.ExpectStatusCodes(HttpStatusCode.OK);
            Assert.IsNotNull(account.Data);
            Assert.AreEqual(1, account.Data.Count);
            Assert.AreEqual(userRef, Guid.Parse(account.Data.Last().UserRef));
        }
        public async Task ThenTheStatusShouldBeFound_ByHashedAccountId()
        {
            var callRequirements =
                new CallRequirements($"api/accounts/{_employerAccount.AccountOutput.HashedAccountId}/legalentities");

            // Act
            var account = await _tester.InvokeGetAsync <ResourceList>(callRequirements);

            // Assert
            Assert.IsNotNull(account.Data);
            Assert.AreEqual(2, account.Data.Count);

            var idsFromApi = account.Data.Select(a => long.Parse(a.Id, NumberStyles.None)).ToArray();

            var idsFromDatabase = _employerAccount.LegalEntities
                                  .Select(le => le.LegalEntityWithAgreementInputOutput.LegalEntityId)
                                  .Union(new[] { _employerAccount.AccountOutput.LegalEntityId })
                                  .ToArray();

            Assert.AreEqual(2, idsFromDatabase.Length,
                            "Not the correct number of legal entities created for this test");

            CheckThatApiReturnedAllLegalEntitiesInDatabase(idsFromDatabase, idsFromApi);
            CheckThatApiReturnedOnlyLegalEntitiesInTheDatabase(idsFromDatabase, idsFromApi);
        }
        public async Task Setup()
        {
            _apiTester = new ApiIntegrationTester();
            var accountStatisticsDataHelper = new AccountStatisticsDataHelper();
            var financeStatisticsDataHelper = new FinanceStatisticsDataHelper();

            _expectedStatisticsViewModel = await accountStatisticsDataHelper.GetStatistics();

            if (AnyAccountStatisticsAreZero(_expectedStatisticsViewModel))
            {
                await accountStatisticsDataHelper.CreateAccountStatistics();

                _expectedStatisticsViewModel = await accountStatisticsDataHelper.GetStatistics();
            }

            var financialStatistics = await financeStatisticsDataHelper.GetStatistics();

            if (AnyFinanceStatisticsAreZero(financialStatistics))
            {
                await financeStatisticsDataHelper.CreateFinanceStatistics();

                financialStatistics = await financeStatisticsDataHelper.GetStatistics();
            }

            _expectedStatisticsViewModel.TotalPayments = financialStatistics.TotalPayments;

            _actualResponse = await _apiTester.InvokeGetAsync <StatisticsViewModel>(new CallRequirements("api/statistics"));
        }
        public async Task ThenTheStatusShouldBeFound_ByHashedAccountId()
        {
            var callRequirements = new CallRequirements($"api/accounts/{_employerAccount.HashedAccountId}/legalentities");

            // Act
            var account = await _tester.InvokeGetAsync <ResourceList>(callRequirements);

            // Assert
            Assert.IsNotNull(account.Data);
            Assert.AreEqual(1, account.Data.Count);
        }
        public async Task ThenTheStatusShouldBeNotFound_ByHashedId()
        {
            // Arrange
            var callRequirements = new CallRequirements("api/accounts/MADE*UP*ID/legalentities");

            // Act
            var returnResponse = await _tester.InvokeGetAsync <ResourceList>(callRequirements);

            // Assert
            returnResponse.ExpectStatusCodes(HttpStatusCode.NotFound);
            Assert.Pass("Verified we got http status NotFound");
        }
Exemplo n.º 9
0
        public async Task ThenTheStatusShouldBeOK_AndDataShouldContainZeroUsers()
        {
            // Arrange
            var callRequirements = new CallRequirements($"api/accounts/MADE*UP*ID/users");

            // Act
            var response = await _tester.InvokeGetAsync <ICollection <TeamMemberViewModel> >(callRequirements);

            // Assert
            response.ExpectControllerType(typeof(EmployerAccountsController));
            response.ExpectStatusCodes(HttpStatusCode.OK);
            Assert.AreEqual(0, response.Data.Count);

            Assert.Pass("Verified we got http status OK");
        }