public void WithExponentialBackoffOn() { var defaultBackOff = new ClientConfig.Builder() { Hostname = ClientConfig.Environments.Sandbox, ConsumerKey = "key", ConsumerSecret = "secret", ExponentialBackoffConfig = new ExponentialBackoffConfig.On(5, 500, (res, t) => { Console.WriteLine("RETRYING"); }) }; var client = new Client.Impl.HttpClient(defaultBackOff, "http", "localhost", port, ServiceUnavailableMockModule.BasePath); var task1 = client.sendAsyncRequestWithResult(HttpMethod.Post, "first", ""); task1.Wait(); Assert.AreEqual("first", task1.Result); var task2 = client.sendAsyncRequestWithResult(HttpMethod.Post, "second", ""); task2.Wait(); Assert.AreEqual("second", task2.Result); var task3 = client.sendAsyncRequestWithResult(HttpMethod.Post, "third", ""); task3.Wait(); Assert.AreEqual("third", task3.Result); }
public void CompressionEnabledDefault() { var client = new Client.Impl.HttpClient(config, "http", "localhost", port, SucceedAPIsMockModule.BasePath); var task = client.sendAsyncRequestWithResult(HttpMethod.Post, "compressed", SucceedAPIsMockModule.TestJsonString); task.Wait(); Assert.AreEqual(SucceedAPIsMockModule.TestJsonString, task.Result); }
public void InitializationWithToken() { var otherConfig = new ClientConfig.Builder() { Hostname = ClientConfig.Environments.Sandbox, Token = "token" }; var client = new Client.Impl.HttpClient(otherConfig, "http", "localhost", port, SucceedAPIsMockModule.BasePath); var task = client.sendAsyncRequestWithResult(HttpMethod.Post, "tokencheck"); task.Wait(); Assert.AreEqual("Bearer token", task.Result); }
public void ByDefaultNoExponentialBackoff() { var defaultBackOff = new ClientConfig.Builder() { Hostname = ClientConfig.Environments.Sandbox, ConsumerKey = "key", ConsumerSecret = "secret" }; var client = new Client.Impl.HttpClient(defaultBackOff, "http", "localhost", port, ServiceUnavailableMockModule.BasePath); Assert.That(() => client.sendAsyncRequestWithResult(HttpMethod.Post, "first", "").Wait(), Throws.TypeOf <AggregateException>() .With.InnerException.TypeOf <InvalidOperationException>() .With.InnerException.Message.EqualTo("status code: ServiceUnavailable, message service out")); }
public void CompressionEnabledForceTrue() { var configWithCompression = new ClientConfig.Builder() { Hostname = ClientConfig.Environments.Sandbox, ConsumerKey = "key", ConsumerSecret = "secret", CompressionEnabled = true }; var client = new Client.Impl.HttpClient(configWithCompression, "http", "localhost", port, SucceedAPIsMockModule.BasePath); var task = client.sendAsyncRequestWithResult(HttpMethod.Post, "compressed", SucceedAPIsMockModule.TestJsonString); task.Wait(); Assert.AreEqual(SucceedAPIsMockModule.TestJsonString, task.Result); }