public void Setup() { //Mock HttpMessageHandler of HttpClient var handlerMock = new Mock <HttpMessageHandler>(MockBehavior.Strict); handlerMock .Protected() // Setup the PROTECTED method to mock .Setup <Task <HttpResponseMessage> >( "SendAsync", ItExpr.IsAny <HttpRequestMessage>(), ItExpr.IsAny <CancellationToken>() ) // prepare the expected response of the mocked http call .ReturnsAsync(new HttpResponseMessage() { StatusCode = HttpStatusCode.OK, Content = new StringContent(UserData.UserDataString()), }) .Verifiable(); // use real http client with mocked handler here var httpClient = new HttpClient(handlerMock.Object) { BaseAddress = new Uri("http://test.com/"), }; mockAPIService = new APIService(httpClient); mockdistanceCalculationService = new DistanceCalculationService(); mockUserFilterService = new UserFilterService(mockAPIService, mockdistanceCalculationService); }
public void Init() { var options = new DbContextOptionsBuilder <DataContext>() .UseInMemoryDatabase(Guid.NewGuid().ToString()) .Options; var unitOfWork = new UnitOfWork(new DataContext(options)); _distanceCalculationService = new DistanceCalculationService(unitOfWork); }
public ProviderSearchService( IProviderDataService providerDataService, IJourneyService journeyService, IDistanceCalculationService distanceCalculationService, ILogger <ProviderSearchService> logger) { _providerDataService = providerDataService ?? throw new ArgumentNullException(nameof(providerDataService)); _journeyService = journeyService ?? throw new ArgumentNullException(nameof(journeyService)); _distanceCalculationService = distanceCalculationService ?? throw new ArgumentNullException(nameof(distanceCalculationService)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public ProviderSearchServiceUnitTests() { _providerDataService = Substitute.For <IProviderDataService>(); _journeyService = Substitute.For <IJourneyService>(); _distanceCalculationService = Substitute.For <IDistanceCalculationService>(); var logger = Substitute.For <ILogger <ProviderSearchService> >(); _service = new ProviderSearchService( _providerDataService, _journeyService, _distanceCalculationService, logger); }
public DistanceCalculationServiceUnitTests() { _locationApiClient = Substitute.For <ILocationApiClient>(); var dateTimeService = Substitute.For <IDateTimeService>(); var logger = Substitute.For <ILogger <DistanceCalculationService> >(); var cache = Substitute.For <IMemoryCache>(); var configuration = new ConfigurationOptions { PostcodeCacheExpiryInSeconds = 120 }; _distanceCalculationService = new DistanceCalculationService( _locationApiClient, dateTimeService, cache, configuration, logger); }
/// <summary> /// Constructs <see cref="CarFitClientCleaningListJobItemDataConvertHelper"/> /// </summary> /// <param name="distanceCalculationService">An implmentation of <see cref="IDistanceCalculationService"/></param> public CarFitClientCleaningListJobItemDataConvertHelper(IDistanceCalculationService distanceCalculationService) { _distanceCalculationService = distanceCalculationService; }
public CalculationController(IDistanceCalculationService distanceCalculationService) { _distanceCalculationService = distanceCalculationService; }
public CalculateDistanceController(ILogger <CalculateDistanceController> logger, IDistanceCalculationService distanceCalculationService) { _logger = logger; _distanceCalculationService = distanceCalculationService; }
public UserFilterService(IAPIService apiService, IDistanceCalculationService distanceCalculationService) { this.apiService = apiService; this.distanceCalculationService = distanceCalculationService; }
public HomeController(IAPIService apiService, IUserFilterService userFilterService, IDistanceCalculationService distanceCalculationService) { this.apiService = apiService; this.userFilterService = userFilterService; this.distanceCalculationService = distanceCalculationService; }
public HomeController() { apiService = new APIService(Client); distanceCalculationService = new DistanceCalculationService(); userFilterService = new UserFilterService(apiService, distanceCalculationService); }
public FileInteractionRepository(IDistanceCalculationService distanceCalculationService) { _distanceCalculationService = distanceCalculationService; }
public DistanceCalculationServiceUnitTests() { _locationApiClient = Substitute.For <ILocationApiClient>(); _distanceCalculationService = new DistanceCalculationService(_locationApiClient); }
public void Setup() { mockDistanceCalculationService = new DistanceCalculationService(); }