public async Task GivenACompanyHouseSearchClient_WhenSearchingForAOfficer()
        {
            var fixture = new Fixture();
            var items = fixture.Build<Item>()
                .With(x => x.Kind, "searchresults#officer")
                .CreateMany().ToArray();
            _resourceDetails = fixture.Build<ResourceDetails>()
                .With(x => x.Officers, items)
                .Create();
            
            var uri = new Uri("https://wibble.com/search/companies");

            var resource = new OfficerSearchResourceBuilder()
                .CreateResource(_resourceDetails);

            HttpMessageHandler handler = new StubHttpMessageHandler(uri, resource);

            var uriBuilder = new Mock<ISearchUriBuilder>();
            uriBuilder.Setup(x => x.Build(It.IsAny<SearchRequest>()))
                .Returns(uri);

            var uriBuilderFactory = new Mock<ISearchUriBuilderFactory>();
            uriBuilderFactory.Setup(x => x.Create<OfficerSearch>())
                .Returns(uriBuilder.Object);

            _client = new CompaniesHouseSearchClient(new HttpClient(handler), uriBuilderFactory.Object);

            _result = await _client.SearchAsync<OfficerSearch>(new SearchRequest());
        }
       public string CreateResource(ResourceDetails resourceDetails)
       {
           return $@"{{
 ""items_per_page"": {resourceDetails.ItemsPerPage},
 ""start_index"": {resourceDetails.StartIndex},
 ""page_number"": {resourceDetails.PageNumber},
 ""total_results"": {resourceDetails.TotalResults},
 ""items"": [
       {string.Join(", ", CreateItems(resourceDetails.Officers))}
   ],
 ""kind"": ""{resourceDetails.Kind}""
 }}";
       }
Esempio n. 3
0
       public string CreateResource(ResourceDetails resourceDetails)
       {
           return($@"{{
 ""items_per_page"": {resourceDetails.ItemsPerPage},
 ""start_index"": {resourceDetails.StartIndex},
 ""page_number"": {resourceDetails.PageNumber},
 ""total_results"": {resourceDetails.TotalResults},
 ""items"": [
       {string.Join(", ", CreateItems(resourceDetails.Officers))}
   ],
 ""kind"": ""{resourceDetails.Kind}""
 }}");
       }