public void ReproAbortedRequest() { TestRequestFactory factory = new TestRequestFactory(); var requestController = new RequestController(TimeSpan.FromSeconds(0), 2, factory, new ErrorResponseDTOJsonExceptionFactory(), new ThrottedRequestQueue(TimeSpan.FromSeconds(5), 30, 10, "data"), new ThrottedRequestQueue(TimeSpan.FromSeconds(3), 1, 3, "trading")); var ctx = new CIAPI.Rpc.Client(new Uri(TestConfig.RpcUrl), requestController); ctx.UserName = TestConfig.ApiUsername; ctx.Session = TestConfig.ApiTestSessionId; factory.CreateTestRequest("{}", TimeSpan.FromMinutes(1)); ctx.Market.GetMarketInformation("FOO"); }
private CIAPI.Rpc.Client BuildClientAndSetupResponse(string expectedJson) { var requestFactory = new TestRequestFactory(); requestFactory.CreateTestRequest(expectedJson); var ctx = new CIAPI.Rpc.Client(new Uri(TestConfig.RpcUrl), new RequestCache(), requestFactory, _standardThrottleScopes, 3); return ctx; }
public void SpecificRequestExceptionsAreRetriedTheCorrectNumberOfTimes() { Console.WriteLine("SpecificRequestExceptionsAreRetriedTheCorrectNumberOfTimes"); using (var gate = new ManualResetEvent(false)) { var requestFactory = new TestRequestFactory(); const int EXPECTED_RETRY_COUNT = 2; var ctx = new CIAPI.Rpc.Client(new Uri(TestConfig.RpcUrl), new RequestCache(), requestFactory, _standardThrottleScopes, EXPECTED_RETRY_COUNT) { UserName = TestConfig.ApiUsername, SessionId = TestConfig.ApiTestSessionId }; requestFactory.CreateTestRequest(NewsHeadlines14, TimeSpan.FromMilliseconds(300), null, null, new WebException("(500) internal server error")); Exception exception = null; ctx.BeginListNewsHeadlines("UK", 14, ar => { try { ctx.EndListNewsHeadlines(ar); } catch (Exception ex) { exception = ex; } finally { gate.Set(); } }, null); gate.WaitOne(TimeSpan.FromSeconds(3)); Assert.IsNotNull(exception); Assert.AreEqual(string.Format("(500) internal server error\r\nretried {0} times", EXPECTED_RETRY_COUNT),exception.Message); } }
private CIAPI.Rpc.Client BuildClientAndSetupResponse(string expectedJson) { TestRequestFactory factory = new TestRequestFactory(); var requestController = new RequestController(TimeSpan.FromSeconds(0), 2, factory, new ErrorResponseDTOJsonExceptionFactory(), new ThrottedRequestQueue(TimeSpan.FromSeconds(5), 30, 10, "data"), new ThrottedRequestQueue(TimeSpan.FromSeconds(3), 1, 3, "trading")); var ctx = new CIAPI.Rpc.Client(new Uri(TestConfig.RpcUrl), requestController); factory.CreateTestRequest(expectedJson); return ctx; }