示例#1
0
        public When_Proximity_BackFillProviderPostTown_Function_Fires()
        {
            var opportunityItemRepository = Substitute.For <IRepository <OpportunityItem> >();

            _providerVenueRepository = Substitute.For <IRepository <ProviderVenue> >();
            _providerVenueRepository.GetManyAsync(Arg.Any <Expression <Func <ProviderVenue, bool> > >())
            .Returns(new List <ProviderVenue> {
                new ProviderVenue
                {
                    Postcode = "CV1 2WT",
                    Town     = null
                }
            }.AsQueryable());

            _functionLogRepository = Substitute.For <IRepository <FunctionLog> >();

            _googleMapsApiClient = Substitute.For <IGoogleMapApiClient>();
            _googleMapsApiClient.GetAddressDetailsAsync("CV1 2WT").Returns("Coventry");

            var locationApiClient = Substitute.For <ILocationApiClient>();

            var proximityFunctions = new Functions.Proximity(
                locationApiClient,
                _googleMapsApiClient,
                opportunityItemRepository,
                _providerVenueRepository,
                _functionLogRepository);

            proximityFunctions.BackFillProviderPostTownAsync(
                new TimerInfo(new ConstantSchedule(TimeSpan.Zero), null),
                new ExecutionContext(),
                new NullLogger <Functions.Proximity>()
                ).GetAwaiter().GetResult();
        }
示例#2
0
        public When_Proximity_BackFillProximityData_Function_Fires()
        {
            var opportunityItemRepository = Substitute.For <IRepository <OpportunityItem> >();

            _providerVenueRepository = Substitute.For <IRepository <ProviderVenue> >();
            var mockProviderVenueDbSet = new List <ProviderVenue>
            {
                new ProviderVenue
                {
                    Postcode = "CV1 2WT",
                    Town     = null
                }
            }
            .AsQueryable()
            .BuildMockDbSet();

            _providerVenueRepository.GetManyAsync(Arg.Any <Expression <Func <ProviderVenue, bool> > >())
            .Returns(mockProviderVenueDbSet);

            _functionLogRepository = Substitute.For <IRepository <FunctionLog> >();

            var googleMapsApiClient = Substitute.For <IGoogleMapApiClient>();

            googleMapsApiClient.GetAddressDetailsAsync("CV1 2WT").Returns("Coventry");

            _locationApiClient = Substitute.For <ILocationApiClient>();
            _locationApiClient.GetGeoLocationDataAsync(Arg.Any <string>(), Arg.Any <bool>())
            .Returns(new PostcodeLookupResultDto
            {
                Postcode  = "CV1 2WT",
                Latitude  = "52.400997",
                Longitude = "-1.508122"
            });

            var proximityFunctions = new Functions.Proximity(
                _locationApiClient,
                googleMapsApiClient,
                opportunityItemRepository,
                _providerVenueRepository,
                _functionLogRepository);

            proximityFunctions.BackFillProximityDataAsync(
                new TimerInfo(new ConstantSchedule(TimeSpan.Zero), null),
                new ExecutionContext(),
                new NullLogger <Functions.Proximity>()
                ).GetAwaiter().GetResult();
        }