public void ReflectValueNotAsync()
        {
            using (MockHttpServer.Json(x => x))
            {
                var client = HttpApiClient <IReflectValue> .Create("http://localhost:8844/pathnotasync", httpHandler : new WebRequestHttpHandler());

                var result = client.ReflectValueNotAsync("foo");
                Assert.AreEqual("foo", result);
            }
        }
Esempio n. 2
0
        public async Task ReflectValue()
        {
            using (MockHttpServer.Json(x => x))
            {
                var client = HttpApiClient <IReflectValue> .Create("http://localhost:8844/path");

                var result = await client.ReflectValue("foo");

                Assert.AreEqual("foo", result);
            }
        }
Esempio n. 3
0
        public async Task RawResponseBody()
        {
            using (MockHttpServer.Json(x => x))
            {
                var client = HttpApiClient <IRawResponseBody> .Create("http://localhost:8844/path");

                var result = await client.GetString("foo");

                Assert.AreEqual("foo", (string)((JsonHttpBody)result).Json);
            }
        }
Esempio n. 4
0
        public async Task RawRequestBody()
        {
            using (MockHttpServer.Json(x => x))
            {
                var client = HttpApiClient <IRawRequestBody> .Create("http://localhost:8844/path");

                var result = await client.GetString(new JsonHttpBody("foo"));

                Assert.AreEqual("foo", result);
            }
        }
Esempio n. 5
0
        public async Task SingleArgumentAsObject()
        {
            using (MockHttpServer.Json(x => x["value"]))
            {
                var client = HttpApiClient <ISingleArgumentAsObject> .Create("http://localhost:8844/path");

                var result = await client.GetString("foo");

                Assert.AreEqual("foo", result);
            }
        }
Esempio n. 6
0
        public async Task JsonNameOverride()
        {
            using (MockHttpServer.Json(x => (string)x["val1"] + x["val2"]))
            {
                var client = HttpApiClient <INameOverride> .Create("http://localhost:8844/path");

                var result = await client.GetString("foo", "bar");

                Assert.AreEqual("foobar", result);
            }
        }
Esempio n. 7
0
        public async Task Override()
        {
            using (MockHttpServer.Json(x => x))
            {
                var client = HttpApiClient <OverrideApi> .Create("http://localhost:8844");

                var result = await client.ReflectString("foo");

                Assert.AreEqual("foobargoat", result);
            }
        }
Esempio n. 8
0
        public async Task Put()
        {
            User user = null;

            using (MockHttpServer.Json(request =>
            {
                user = new User {
                    Id = 1, FirstName = "John", LastName = "Doe"
                };
            }))
            {
                var client = HttpApiClient <ICrudApi <User> > .Create("http://localhost:8844");

                await client.Put(1, new User { Id = 1, FirstName = "John", LastName = "Doe" });

                Assert.AreEqual(1, user.Id);
                Assert.AreEqual("John", user.FirstName);
                Assert.AreEqual("Doe", user.LastName);
            }
        }