public void GivenACompanyHouseSearchCompanyClient_WhenSearchingForACompany()
        {
            var fixture = new Fixture();
            _resourceDetails = fixture.Create<ResourceDetails>();
            _expectedCompanies = new List<CompanyDetails>
            {
                fixture.Build<CompanyDetails>().With(x => x.CompanyStatus, "active").With(x => x.CompanyType, "private-unlimited").Create(),
                fixture.Build<CompanyDetails>().With(x => x.CompanyStatus, "dissolved").With(x => x.CompanyType, "private-unlimited").Create(),
                fixture.Build<CompanyDetails>().With(x => x.CompanyStatus, "liquidation").With(x => x.CompanyType, "private-unlimited").Create(),
                fixture.Build<CompanyDetails>().With(x => x.CompanyStatus, "receivership").With(x => x.CompanyType, "private-unlimited").Create(),
                fixture.Build<CompanyDetails>().With(x => x.CompanyStatus, "administration").With(x => x.CompanyType, "private-unlimited").Create(),
                fixture.Build<CompanyDetails>().With(x => x.CompanyStatus, "voluntary-arrangement").With(x => x.CompanyType, "private-unlimited").Create(),
                fixture.Build<CompanyDetails>().With(x => x.CompanyStatus, "converted-closed").With(x => x.CompanyType, "private-unlimited").Create(),
                fixture.Build<CompanyDetails>().With(x => x.CompanyStatus, "insolvency-proceedings").With(x => x.CompanyType, "private-unlimited").Create(),
            };

            var uri = new Uri("https://wibble.com/search/companies");

            var resource = new CompanySearchResourceBuilder()
                .AddCompanies(_expectedCompanies)
                .CreateResource(_resourceDetails);

            HttpMessageHandler handler = new StubHttpMessageHandler(uri, resource);
            var httpClientFactory = new Mock<IHttpClientFactory>();
            httpClientFactory.Setup(x => x.CreateHttpClient())
                .Returns(new HttpClient(handler));

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

            _client = new CompaniesHouseSearchCompanyClient(httpClientFactory.Object, uriBuilder.Object);

            _result = _client.SearchCompanyAsync(new CompanySearchRequest()).Result;
        }
        public string CreateResource(ResourceDetails companySearch)
        {
            var resource =
                $@"{{
   ""etag"": ""{companySearch.ETag}"",
   ""items"" : [
      {string.Join(", ", _itemBlocks)}
   ],
   ""items_per_page"" : {companySearch.ItemsPerPage},
   ""kind"" : ""{companySearch.Kind}"",
   ""page_number"" : {companySearch.PageNumber},
   ""start_index"" : {companySearch.StartIndex},
   ""total_results"" : {companySearch.TotalResults}
}}";
            return resource;
        }
示例#3
0
        public string CreateResource(ResourceDetails companySearch)
        {
            var resource =
                $@"{{
   ""etag"": ""{companySearch.ETag}"",
   ""items"" : [
      {string.Join(", ", _itemBlocks)}
   ],
   ""items_per_page"" : {companySearch.ItemsPerPage},
   ""kind"" : ""{companySearch.Kind}"",
   ""page_number"" : {companySearch.PageNumber},
   ""start_index"" : {companySearch.StartIndex},
   ""total_results"" : {companySearch.TotalResults}
}}";

            return(resource);
        }