Exemplo n.º 1
0
        public void SearchOrganisations_WithValidParams_ShouldCallTheApiWithTheCorrectUrl()
        {
            var fixtures = new ReferenceDataApiClientTestFixtures()
                           .WithBaseUrl(@"http://some-url/api/organisations/")
                           .WithSearchOrganisationsResult(searchTerm, maximumResults, new Organisation());

            fixtures.GetOrganisationSearch(searchTerm, maximumResults);

            fixtures.ChackUrlCalled(fixtures.BuildSearchOrganisationUrl(searchTerm, maximumResults));
        }
Exemplo n.º 2
0
        public void SearchPublicSectorOrganisation_WithTrickyParams_ShouldEncodeParamsCorrectly()
        {
            var fixtures = new ReferenceDataApiClientTestFixtures()
                           .WithBaseUrl(@"http://some-url/api/organisations/")
                           .WithSearchPublicSectorResult(complexSearchTerm, startPage, pageSize, new PublicSectorOrganisation());

            fixtures.GetSearchPublicSectorAsync(complexSearchTerm);

            fixtures.ChackUrlCalled(fixtures.BuildSearchPublicSectorUrl(complexSearchTerm, startPage, pageSize));
        }
Exemplo n.º 3
0
        public void SearchPublicSectorOrganisation_WithValidParams_ShouldCallTheApiWithTheCorrectUrl()
        {
            var fixtures = new ReferenceDataApiClientTestFixtures()
                           .WithBaseUrl(@"http://some-url/api/organisations/")
                           .WithSearchPublicSectorResult(searchTerm, startPage, pageSize, new PublicSectorOrganisation());

            fixtures.GetSearchPublicSectorAsync(searchTerm);

            fixtures.ChackUrlCalled(fixtures.BuildSearchPublicSectorUrl(searchTerm, startPage, pageSize));
        }
Exemplo n.º 4
0
        public void SearchOrganisations_WithTrickyParams_ShouldEncodeParamsCorrectly()
        {
            var fixtures = new ReferenceDataApiClientTestFixtures()
                           .WithBaseUrl(@"http://some-url/api/organisations/")
                           .WithSearchOrganisationsResult(complexSearchTerm, maximumResults, new Organisation());

            fixtures.GetOrganisationSearch(complexSearchTerm, maximumResults);

            fixtures.ChackUrlCalled(fixtures.BuildSearchOrganisationUrl(complexSearchTerm, maximumResults));
        }
Exemplo n.º 5
0
        public async Task GetCharity_ExistingCharityOrNot_ShouldCallExpectedUrl()
        {
            const int charityNumber   = 123;
            var       expectedCharity = new Charity {
                RegistrationNumber = charityNumber
            };

            var fixtures = new ReferenceDataApiClientTestFixtures()
                           .WithBaseUrl(@"http://some-url/api/organisations/")
                           .WithCharityResponse(charityNumber, expectedCharity);

            await fixtures.GetCharityAsync(charityNumber);

            fixtures.ChackUrlCalled($"{fixtures.BaseUrl}charities/{charityNumber}");
        }
Exemplo n.º 6
0
        public void GetLatestDetails_SpecifiedStatusCode_ShouldCauseExpectedExceptionInClient(
            OrganisationType organisationType,
            string registeredId,
            HttpStatusCode statusCode,
            Type expectedException)
        {
            var expectedOrganisation = new Organisation {
                Code = registeredId
            };

            var fixtures = new ReferenceDataApiClientTestFixtures()
                           .WithBaseUrl(@"http://some-url/api/organisations/")
                           .WithGetLatestDetailsResponse(organisationType, registeredId, expectedOrganisation, statusCode);

            Assert.ThrowsAsync(expectedException, () => fixtures.GetLatestDetailsAsync(organisationType, registeredId));
        }