Ejemplo n.º 1
0
        public async void TestMethodCallWithCancellationToken()
        {
            var cancellationTokenSource = new CancellationTokenSource();

            cancellationTokenSource.Cancel();

            var      host        = "http://api.test.com";
            dynamic  test_client = new MockClient(host: host);
            Response response    = await test_client.get(cancellationToken : cancellationTokenSource.Token);
        }
Ejemplo n.º 2
0
        public async void TestMethodCall()
        {
            var      host        = "http://api.test.com";
            dynamic  test_client = new MockClient(host: host);
            Response response    = await test_client.get();

            Assert.IsNotNull(response);
            Assert.AreEqual(response.StatusCode, HttpStatusCode.OK);
            var content = new StringContent("{'test': 'test_content'}", Encoding.UTF8, "application/json");

            Assert.AreEqual(response.Body.ReadAsStringAsync().Result, content.ReadAsStringAsync().Result);
        }
Ejemplo n.º 3
0
        public void TestReflection()
        {
            var     host        = "http://api.test.com";
            dynamic test_client = new MockClient(host: host);
            dynamic url1        = test_client.my.test.path;

            Assert.AreEqual(url1.UrlPath, "/my/test/path");
            url1 = test_client.my._("test").path;
            Assert.AreEqual(url1.UrlPath, "/my/test/path");
            url1 = test_client.version("v4").my.test.path;
            Assert.AreEqual(url1.Version, "v4");
            Assert.AreEqual(url1.UrlPath, "/my/test/path");
            url1 = url1.final.result;
            Assert.AreEqual(url1.UrlPath, "/my/test/path/final/result");
        }
Ejemplo n.º 4
0
        public void TestInitialization()
        {
            var host = "http://api.test.com";
            Dictionary <String, String> requestHeaders = new Dictionary <String, String>();
            var version     = "v3";
            var urlPath     = "/test/url/path";
            var test_client = new MockClient(host: host, requestHeaders: requestHeaders, version: version, urlPath: urlPath);

            requestHeaders.Add("Authorization", "Bearer SG.XXXX");
            requestHeaders.Add("Content-Type", "application/json");
            requestHeaders.Add("X-TEST", "test");
            Assert.IsNotNull(test_client);
            Assert.AreEqual(host, test_client.Host);
            Assert.AreEqual(requestHeaders, test_client.RequestHeaders);
            Assert.AreEqual(version, test_client.Version);
            Assert.AreEqual(urlPath, test_client.UrlPath);
        }