コード例 #1
0
 public CachedLookupServiceTests()
 {
     _mockHttpCallsHandler = new Mock <IHttpCallsHandler>();
     _mockDistributedCache = new Mock <IDistributedCache>();
     _dummyCountriesData   = new DummyCountriesData();
     _cachedLookupService  = new CachedLookupService(_mockHttpCallsHandler.Object, _mockDistributedCache.Object);
 }
コード例 #2
0
        public async Task Search()
        {
            var client        = IocConfig.CreateHttpClient();
            var clientWrapper = new HttpClientWrapper(client, IocConfig.CreateJsonMediaTypeFormatter());

            var cls = new CachedLookupService(new LookupApiService(clientWrapper, new SecurityApiService(clientWrapper)), new CacheAccessor(new JsonConverterCollection()
            {
                new DbGeographyConverter()
            }));
            var las = await cls.LocalAuthorityGetAllAsync();

            var pcs = await cls.ParliamentaryConstituenciesGetAllAsync();

            var ets = await cls.EstablishmentTypesGetAllAsync();

            var gors = await cls.GovernmentOfficeRegionsGetAllAsync();

            var GSSLAs = await cls.GSSLAGetAllAsync();

            var dios = await cls.DiocesesGetAllAsync();

            var dis = await cls.AdministrativeDistrictsGetAllAsync();

            var subject = new EstablishmentReadApiService(clientWrapper, null);
            var result  = await subject.SearchAsync(new EstablishmentSearchPayload
            {
                Skip    = 0,
                Take    = 100,
                Filters = new EstablishmentSearchFilters
                {
                    LocalAuthorityIds            = las.Select(x => x.Id).Skip(1).ToArray(),
                    ParliamentaryConstituencyIds = pcs.Select(x => x.Id).Skip(1).ToArray(),
                    TypeIds = ets.Select(x => x.Id).Skip(1).ToArray(),
                    GovernmentOfficeRegionIds = gors.Select(x => x.Id).Skip(1).ToArray(),
                    GSSLAIds   = GSSLAs.Select(x => x.Id).Skip(1).ToArray(),
                    DioceseIds = dios.Select(x => x.Id).Skip(1).ToArray(),
                    AdministrativeDistrictIds = dis.Select(x => x.Id).Skip(1).ToArray(),
                }
            }, new GenericPrincipal(new GenericIdentity(""), new string[0]));

            Assert.IsTrue(result.Items.Count == 100);
        }