コード例 #1
0
        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);
        }
コード例 #2
0
        public void Init()
        {
            var options = new DbContextOptionsBuilder <DataContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;
            var unitOfWork = new UnitOfWork(new DataContext(options));

            _distanceCalculationService = new DistanceCalculationService(unitOfWork);
        }
コード例 #3
0
 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);
    }
コード例 #5
0
    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);
    }
コード例 #6
0
 /// <summary>
 /// Constructs <see cref="CarFitClientCleaningListJobItemDataConvertHelper"/>
 /// </summary>
 /// <param name="distanceCalculationService">An implmentation of <see cref="IDistanceCalculationService"/></param>
 public CarFitClientCleaningListJobItemDataConvertHelper(IDistanceCalculationService distanceCalculationService)
 {
     _distanceCalculationService = distanceCalculationService;
 }
コード例 #7
0
 public CalculationController(IDistanceCalculationService distanceCalculationService)
 {
     _distanceCalculationService = distanceCalculationService;
 }
 public CalculateDistanceController(ILogger <CalculateDistanceController> logger, IDistanceCalculationService distanceCalculationService)
 {
     _logger = logger;
     _distanceCalculationService = distanceCalculationService;
 }
コード例 #9
0
 public UserFilterService(IAPIService apiService, IDistanceCalculationService distanceCalculationService)
 {
     this.apiService = apiService;
     this.distanceCalculationService = distanceCalculationService;
 }
コード例 #10
0
 public HomeController(IAPIService apiService, IUserFilterService userFilterService, IDistanceCalculationService distanceCalculationService)
 {
     this.apiService                 = apiService;
     this.userFilterService          = userFilterService;
     this.distanceCalculationService = distanceCalculationService;
 }
コード例 #11
0
 public HomeController()
 {
     apiService = new APIService(Client);
     distanceCalculationService = new DistanceCalculationService();
     userFilterService          = new UserFilterService(apiService, distanceCalculationService);
 }
コード例 #12
0
 public FileInteractionRepository(IDistanceCalculationService distanceCalculationService)
 {
     _distanceCalculationService = distanceCalculationService;
 }
 public DistanceCalculationServiceUnitTests()
 {
     _locationApiClient          = Substitute.For <ILocationApiClient>();
     _distanceCalculationService = new DistanceCalculationService(_locationApiClient);
 }
コード例 #14
0
 public void Setup()
 {
     mockDistanceCalculationService = new DistanceCalculationService();
 }