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 ThenTheStatusShouldBeFound()
        {
            // Arrange
            string hashedAccountId = null;
            await _tester.InitialiseData <EmployerAccountsDbBuilder>(async builder =>
            {
                var data = new TestModelBuilder()
                           .WithNewUser()
                           .WithNewAccount()
                           .WithNewLegalEntity();

                await builder.SetupDataAsync(data);

                hashedAccountId = data.CurrentAccount.AccountOutput.HashedAccountId;
            });

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

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

            // Assert
            legalEntities.ExpectStatusCodes(HttpStatusCode.OK);
            legalEntities.ExpectControllerType(typeof(LegalEntitiesController));
            Assert.IsNotNull(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.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");
        }
        public async Task ThenTheStatusShouldBeFound_ByAccountId()
        {
            var callRequirements = new CallRequirements($"api/accounts/internal/{_employerAccount.AccountId}");

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

            // Assert
            account.ExpectControllerType(typeof(EmployerAccountsController));
            account.ExpectStatusCodes(HttpStatusCode.OK);
            Assert.IsNotNull(account.Data);
        }
Пример #7
0
        public async Task ThenTheStatusShouldBeNotFound_ByHashedId()
        {
            // Arrange
            var callRequirements = new CallRequirements($"api/accounts/MADE*UP*ID");

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

            // Assert
            response.ExpectControllerType(typeof(EmployerAccountsController));
            response.ExpectStatusCodes(HttpStatusCode.NotFound);
        }
        public async Task ThenTheStatusShouldBeBadRequest()
        {
            // Arrange
            var callRequirements =
                new CallRequirements("api/accounts/%20/legalentities");

            // Act
            var response = await ApiIntegrationTester.InvokeIsolatedGetAsync(callRequirements);

            // Assert
            response.ExpectControllerType(typeof(LegalEntitiesController));
            response.ExpectValidationError();
        }
Пример #9
0
        public async Task ThenTheStatusShouldBeOk()
        {
            // Arrange
            var call = new CallRequirements("api/HealthCheck");

            // Act
            var response = await ApiIntegrationTester.InvokeIsolatedGetAsync(call);

            // Assert

            response.ExpectStatusCodes(HttpStatusCode.OK);
            Assert.Pass("Verified we got OK");
        }
Пример #10
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");
        }
Пример #11
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");
        }
        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);
        }