Ejemplo n.º 1
0
        //[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);
 }
Ejemplo n.º 3
0
        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;
 }
Ejemplo n.º 5
0
        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;
        }
Ejemplo n.º 6
0
        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;
        }
Ejemplo n.º 7
0
        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();
        }
Ejemplo n.º 8
0
 public PlayersServiceManager(IHttpClientManager httpClientManager,
                              IOptions <EndpointOptions> endpointOptions)
 {
     this.httpClientManager = httpClientManager;
     this.endpointOptions   = endpointOptions;
 }
Ejemplo n.º 9
0
 public CustomerBusinessServices(IHttpClientManager httpClientManager, IConfiguration configuaration, IBetBusinessServices betBusinessServices) : base(httpClientManager, configuaration)
 {
     _httpClientManager   = httpClientManager;
     _configuration       = configuaration;
     _betBusinessServices = betBusinessServices;
 }
Ejemplo n.º 10
0
 public WhitespacesDataClient(IHttpClientManager httpClientManager)
 {
     this.httpManager = httpClientManager;
 }
 public BetBusinessServices(IHttpClientManager httpClientManager, IConfiguration configuration) : base(httpClientManager, configuration)
 {
     _configuration = configuration;
 }
Ejemplo n.º 12
0
 public UsersAppService(IHttpClientManager client, IConfiguration config)
 {
     _client = client;
     _config = config;
 }
Ejemplo n.º 13
0
 public PersonRepository(PeopleDomainSettings peopleDomainSettings, IHttpClientManager httpClientManager)
 {
     _options           = peopleDomainSettings;
     _httpClientManager = httpClientManager;
 }
Ejemplo n.º 14
0
 public BaseBusinessServices(IHttpClientManager httpClientManager, IConfiguration configuration)
 {
     _httpClientManager = httpClientManager;
     _configuration     = configuration;
 }
Ejemplo n.º 15
0
 public ChatServices(IHttpClientManager httpClientManager)
 {
     _httpClientManager = httpClientManager;
 }
Ejemplo n.º 16
0
 /// <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();
 }
Ejemplo n.º 18
0
 public EventService(IHttpClientManager httpClientManager, IConfiguration configuration, IAuthenticationService authenticationService) : base(httpClientManager, configuration)
 {
     _configuration         = configuration;
     _authenticationService = authenticationService;
 }
Ejemplo n.º 19
0
 public PublicDataAccess(IHttpClientManager httpClientManager)
 {
     this.httpManager = httpClientManager;
 }
Ejemplo n.º 20
0
 public PaymentManager(IHttpClientManager httpClientManager,
                       IOptions <EndpointOptions> endpointOptions)
 {
     this.httpClientManager = httpClientManager;
     this.endpointOptions   = endpointOptions;
 }
Ejemplo n.º 21
0
 public AuthenticationService(IHttpClientManager httpClientManager, IConfiguration configuration) : base(httpClientManager, configuration)
 {
     _configuration = configuration;
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Intialize
 /// </summary>
 /// <param name="httpClientManager"></param>
 public NewsFeedManager(IHttpClientManager httpClientManager)
 {
     _httpClientManager = httpClientManager;
 }
Ejemplo n.º 23
0
 public BroadbandDealManager(IHttpClientManager httpClientManager)
 {
     _httpClientManager = httpClientManager;
 }