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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }
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); } }