Ejemplo n.º 1
0
        public async Task GetString()
        {
            using (MockHttpServer.ReturnJson(request => Task.FromResult <JToken>(new JValue("foo"))))
            {
                var client = HttpApiClient <IGetString> .Create("http://localhost:8844/path");

                await client.GetString();
            }
        }
Ejemplo n.º 2
0
        public void GetString()
        {
            using (MockHttpServer.ReturnJson(request => Task.FromResult <JToken>(new JValue("foo"))))
            {
                var client = HttpApiClient <EmitBasedClientTests.IGetString> .Create("http://localhost:8844/path", httpHandler : new WebRequestHttpHandler());

                client.GetString().Wait();
            }
        }
Ejemplo n.º 3
0
        public async Task InstrumentedResponse()
        {
            using (MockHttpServer.ReturnJson(request => request.Headers.Get("Test")))
            {
                var client = HttpApiClient <InstrumentResponseClass> .Create("http://localhost:8844");

                var result = await client.InstrumentedResponse();

                Assert.AreEqual("foo", result);
            }
        }
Ejemplo n.º 4
0
        public async Task CustomizeInvocation()
        {
            using (MockHttpServer.ReturnJson(request => Task.FromResult <JToken>(new JValue("foo"))))
            {
                var client = HttpApiClient <CustomizeInvocationApi> .Create("http://localhost:8844/path");

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

                Assert.AreEqual("foofoo", result);
            }
        }
Ejemplo n.º 5
0
        public async Task GetStringAbstract()
        {
            using (MockHttpServer.ReturnJson(request => Task.FromResult <JToken>(new JValue("foo"))))
            {
                var client = HttpApiClient <GetStringApi> .Create("http://localhost:8844/path");

                var result = await client.GetString();

                Assert.AreEqual("foo", result);
            }
        }
Ejemplo n.º 6
0
        public async Task GetAll()
        {
            using (MockHttpServer.ReturnJson(request => Task.FromResult(JToken.FromObject(new[] { new { Id = 1, FirstName = "John", LastName = "Doe" } }))))
            {
                var client = HttpApiClient <ICrudApi <User> > .Create("http://localhost:8844");

                var users = await client.GetAll();

                Assert.AreEqual(1, users[0].Id);
                Assert.AreEqual("John", users[0].FirstName);
                Assert.AreEqual("Doe", users[0].LastName);
            }
        }
Ejemplo n.º 7
0
        public async Task OtherPropertiesAndMethodsDoNotCauseProblems()
        {
            using (MockHttpServer.ReturnJson("foo"))
            {
                var client = HttpApiClient <ExtraneousMembersClass> .Create("http://localhost:8844");

                client.SomeProperty = "foo";
                Assert.AreEqual("foo", client.SomeProperty);
                Assert.AreEqual("foo", client.SomeMethod("foo"));

                var result = await client.GetString();

                Assert.AreEqual("foo", result);
            }
        }