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)); }
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)); }
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)); }
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)); }
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}"); }
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)); }