public When_OpportunityProximity_Controller_Results_Is_Loaded_With_No_Results_In_Selected_Route() { var providerSearchResultDto = new List <OpportunityProximitySearchResultViewModelItem>(); var providerSearchResultForOtherRoutesDto = new List <OpportunityProximitySearchResultByRouteViewModelItem> { new OpportunityProximitySearchResultByRouteViewModelItem { NumberOfResults = 1, RouteName = "another route" } }; var locationService = Substitute.For <ILocationService>(); locationService.IsValidPostcodeAsync(Arg.Any <string>()).Returns((true, Postcode)); var routeService = Substitute.For <IRoutePathService>(); routeService.GetRouteIdsAsync().Returns(new List <int> { 1, 2 }); _opportunityProximityService = Substitute.For <IOpportunityProximityService>(); _opportunityProximityService .SearchOpportunitiesByPostcodeProximityAsync( Arg.Is <OpportunityProximitySearchParametersDto>( a => a.Postcode == Postcode && a.SelectedRouteId == RouteId)) .Returns(providerSearchResultDto); _opportunityProximityService .SearchOpportunitiesForOtherRoutesByPostcodeProximityAsync( Arg.Is <OpportunityProximitySearchParametersDto>( a => a.Postcode == Postcode && a.SearchRadius == SearchParametersViewModel.ZeroResultsSearchRadius && a.SelectedRouteId == RouteId)) .Returns(providerSearchResultForOtherRoutesDto); _opportunityService = Substitute.For <IOpportunityService>(); var opportunityProximityController = new OpportunityProximityController(routeService, _opportunityProximityService, _opportunityService, locationService); _result = opportunityProximityController.GetOpportunityProviderResultsAsync(new SearchParametersViewModel { SelectedRouteId = RouteId, Postcode = Postcode }).GetAwaiter().GetResult(); }
public When_OpportunityProximity_Controller_Results_Is_Loaded_With_No_Existing_Opportunity() { var providerSearchResultDto = new List <OpportunityProximitySearchResultViewModelItem> { new OpportunityProximitySearchResultViewModelItem { ProviderVenuePostcode = Postcode, Distance = 1.5d } }; var locationService = Substitute.For <ILocationService>(); locationService.IsValidPostcodeAsync(Arg.Any <string>()).Returns((true, Postcode)); var routeService = Substitute.For <IRoutePathService>(); routeService.GetRouteIdsAsync().Returns(new List <int> { 1, 2 }); _opportunityProximityService = Substitute.For <IOpportunityProximityService>(); _opportunityProximityService .SearchOpportunitiesByPostcodeProximityAsync(Arg.Is <OpportunityProximitySearchParametersDto>(a => a.Postcode == Postcode && a.SelectedRouteId == RouteId)) .Returns(providerSearchResultDto); _opportunityService = Substitute.For <IOpportunityService>(); var opportunityProximityController = new OpportunityProximityController(routeService, _opportunityProximityService, _opportunityService, locationService); _result = opportunityProximityController.GetOpportunityProviderResultsAsync(new SearchParametersViewModel { SelectedRouteId = RouteId, Postcode = Postcode }).GetAwaiter().GetResult(); }
public When_OpportunityProximity_Controller_Results_Is_Loaded_With_Existing_Opportunity() { var providerSearchResultDto = new List <OpportunityProximitySearchResultViewModelItem> { new OpportunityProximitySearchResultViewModelItem { ProviderVenuePostcode = Postcode, Distance = 1.5d, ProviderVenueId = ProviderVenueId, ProviderVenueName = ProviderVenueDisplayName, ProviderDisplayName = ProviderDisplayName } }; var locationService = Substitute.For <ILocationService>(); locationService.IsValidPostcodeAsync(Arg.Any <string>()).Returns((true, Postcode)); var routeService = Substitute.For <IRoutePathService>(); routeService.GetRouteIdsAsync().Returns(new List <int> { 1, 2 }); _opportunityProximityService = Substitute.For <IOpportunityProximityService>(); _opportunityProximityService .SearchOpportunitiesByPostcodeProximityAsync(Arg.Is <OpportunityProximitySearchParametersDto>(a => a.Postcode == Postcode && a.SelectedRouteId == RouteId)) .Returns(providerSearchResultDto); _opportunityService = Substitute.For <IOpportunityService>(); _opportunityService.GetOpportunityItemAsync(OpportunityItemId) .Returns(new OpportunityItemDto { OpportunityId = OpportunityId, OpportunityItemId = OpportunityItemId, Postcode = Postcode, RouteId = RouteId }); _opportunityService.GetReferralsAsync(OpportunityItemId).Returns(new List <ReferralDto> { new ReferralDto { ProviderVenueId = ProviderVenueId, Name = "Referral" } }); _opportunityService .GetCompanyNameWithAkaAsync(OpportunityId) .Returns("CompanyName (AlsoKnownAs)"); var opportunityProximityController = new OpportunityProximityController(routeService, _opportunityProximityService, _opportunityService, locationService); _result = opportunityProximityController.GetOpportunityProviderResultsAsync(new SearchParametersViewModel { SelectedRouteId = RouteId, Postcode = Postcode, OpportunityId = OpportunityId, OpportunityItemId = OpportunityItemId }).GetAwaiter().GetResult(); }