//[ExpectedHttpStatusCode(HttpStatusCode.BadRequest)] public void GetPersons_WhenExternalAPIReturnsHTTPBadRequest_ReturnsResponse() { _mockHandler = new Mock <TestableHttpMessageHandler> { CallBase = true }; _httpClient = new System.Net.Http.HttpClient(_mockHandler.Object) { BaseAddress = new Uri(_baseAddress) }; _httpClientManager = Mock.Of <IHttpClientManager>(x => x.GetClient() == _httpClient); _repository = new PersonRepository(_domainSettings, _httpClientManager ); var expression = _mockHandler.CreateSendAsyncExpression(HttpMethod.Get, $"{_baseAddress}{_domainSettings.Path}"); var assume = CreateMockData(); var badRequestResult = CreateHttpResponseMessage(HttpStatusCode.InternalServerError, assume); _mockHandler.Setup(expression).RespondsWith(badRequestResult); try { var response = _repository.GetPersons(string.Empty);//.GetAwaiter().GetResult(); ; } catch (Exception ex) { if (ex is HttpRequestException) { var statusCode = (ex as HttpRequestException); } } // Assert.Fail("HTTP 500 was not thrown"); }
public Worker(IHttpClientManager httpClient, ITokenService tokenService) { _httpClient = httpClient; _tokenService = tokenService; // we want to limit the number of items here _semaphore = new SemaphoreSlim(10); }
public void GetPersons_WhenFilterForPetTypeSpecified_And_ExternalAPIReturnsData_ReturnsPersonsWithPetsFilteredByType() { _mockHandler = new Mock <TestableHttpMessageHandler> { CallBase = true }; _httpClient = new System.Net.Http.HttpClient(_mockHandler.Object) { BaseAddress = new Uri(_baseAddress) }; _httpClientManager = Mock.Of <IHttpClientManager>(x => x.GetClient() == _httpClient); _repository = new PersonRepository(_domainSettings, _httpClientManager ); var expression = _mockHandler.CreateSendAsyncExpression(HttpMethod.Get, $"{_baseAddress}{_domainSettings.Path}"); var result = CreateMockData(); _mockHandler.Setup(expression).RespondsWith(result); var response = _repository.GetPersons("Cat").GetAwaiter().GetResult();; Assert.IsNotNull(response); JsonCompare(CreateMockResponseDataWithFilter(), response, "The result is not expected"); }
public RaceBusinessServices( IHttpClientManager httpClientManager, IConfiguration configuration, IBetBusinessServices betServices) : base(httpClientManager, configuration) { _configuration = configuration; _betServices = betServices; }
public ServerMonitorCache(IHttpClientManager httpClientManager, ITradeViewConfigurationServer configurationServer) { this.httpClientManager = httpClientManager; this.configurationServer = configurationServer; serverMonitors = new ObservableCollection <ServerMonitor>(); serverMonitorSubscriptions = new Dictionary <string, IDisposable>(); dispatcher = Application.Current.Dispatcher; }
public RetryHttpClientManager(IHttpClientManager httpClientManager, RetryPolicy retryPolicy) { if (httpClientManager == null) { throw new ArgumentNullException("httpClientManager"); } if (retryPolicy == null) { throw new ArgumentNullException("retryPolicy"); } this.httpClientManager = httpClientManager; this.retryPolicy = retryPolicy; }
public StrategyRunnerViewModel( ViewModelContext viewModelContext, AccountViewModel accountViewModel, SymbolsViewModel symbolsViewModel, StrategyParametersViewModel strategyParametersViewModel, IStrategyService strategyService, IServerMonitorCache serverMonitorCache, IStrategyAssemblyManager strategyAssemblyManager, IHttpClientManager httpClientManager) : base(viewModelContext) { this.strategyService = strategyService; this.serverMonitorCache = serverMonitorCache; this.strategyAssemblyManager = strategyAssemblyManager; this.httpClientManager = httpClientManager; AccountViewModel = accountViewModel; SymbolsViewModel = symbolsViewModel; StrategyParametersViewModel = strategyParametersViewModel; CanRun = false; CanMonitor = false; IsConnected = false; IsConnecting = false; Notifications = new ObservableCollection <Message>(); RunCommand = new ViewModelCommand(RunStrategy); MonitorCommand = new ViewModelCommand(MonitorStrategy); DisconnectCommand = new ViewModelCommand(Disconnect); StopCommand = new ViewModelCommand(StopStrategy); ClearNotificationsCommand = new ViewModelCommand(ClearNotifications); ObserveSymbols(); ObserveAccount(); ObserveParameters(); ObserveServerMonitorCache(); }
public PlayersServiceManager(IHttpClientManager httpClientManager, IOptions <EndpointOptions> endpointOptions) { this.httpClientManager = httpClientManager; this.endpointOptions = endpointOptions; }
public CustomerBusinessServices(IHttpClientManager httpClientManager, IConfiguration configuaration, IBetBusinessServices betBusinessServices) : base(httpClientManager, configuaration) { _httpClientManager = httpClientManager; _configuration = configuaration; _betBusinessServices = betBusinessServices; }
public WhitespacesDataClient(IHttpClientManager httpClientManager) { this.httpManager = httpClientManager; }
public BetBusinessServices(IHttpClientManager httpClientManager, IConfiguration configuration) : base(httpClientManager, configuration) { _configuration = configuration; }
public UsersAppService(IHttpClientManager client, IConfiguration config) { _client = client; _config = config; }
public PersonRepository(PeopleDomainSettings peopleDomainSettings, IHttpClientManager httpClientManager) { _options = peopleDomainSettings; _httpClientManager = httpClientManager; }
public BaseBusinessServices(IHttpClientManager httpClientManager, IConfiguration configuration) { _httpClientManager = httpClientManager; _configuration = configuration; }
public ChatServices(IHttpClientManager httpClientManager) { _httpClientManager = httpClientManager; }
/// <summary> /// Initializes a new instance of the <see cref="WhitespacesDataClientTests" /> class. /// </summary> public WhitespacesDataClientTests() { this.httpClientManager = new HttpClientManager(ConfigurationManager.AppSettings["AuthorizationSchema"].ToString()); this.whitespacesDataClient = new WhitespacesDataClient(this.httpClientManager); }
public JobBusinessServices(IHttpClientManager httpClientManager, IConfiguration configuration) : base(httpClientManager, configuration) { _configuration = configuration; SkillWeighStrategy = new TJobSkillStrategy(); }
public EventService(IHttpClientManager httpClientManager, IConfiguration configuration, IAuthenticationService authenticationService) : base(httpClientManager, configuration) { _configuration = configuration; _authenticationService = authenticationService; }
public PublicDataAccess(IHttpClientManager httpClientManager) { this.httpManager = httpClientManager; }
public PaymentManager(IHttpClientManager httpClientManager, IOptions <EndpointOptions> endpointOptions) { this.httpClientManager = httpClientManager; this.endpointOptions = endpointOptions; }
public AuthenticationService(IHttpClientManager httpClientManager, IConfiguration configuration) : base(httpClientManager, configuration) { _configuration = configuration; }
/// <summary> /// Intialize /// </summary> /// <param name="httpClientManager"></param> public NewsFeedManager(IHttpClientManager httpClientManager) { _httpClientManager = httpClientManager; }
public BroadbandDealManager(IHttpClientManager httpClientManager) { _httpClientManager = httpClientManager; }