public void RunInvokation() { var httpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent($"\"{HelloWorld}\"", Encoding.UTF8, "application/json") }; _client = new Mock <IHttpClient>(); _client.Setup(s => s.SendAsync(It.IsAny <HttpRequestMessage>())).ReturnsAsync(httpResponseMessage); _invokation = new Mock <IInvocation>(); _invokation.SetupGet(i => i.Method).Returns(typeof(IGreetings).GetMethod("Hello")); _invokation.SetupGet(i => i.Arguments).Returns(new object[] { "+15550127896" }); _invokation.SetupProperty(i => i.ReturnValue); var interceptor = new WebClientRequestInterceptor <IGreetings>("http://localhost", _client.Object, new IActionFilter[0]); interceptor.Intercept(_invokation.Object); }
public void RunInvokation() { var httpResponseMessage = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent("{\"name\": \"John Doe\", \"age\":47}", Encoding.UTF8, "application/json") }; _client = new Mock <IHttpClient>(); _client.Setup(s => s.SendAsync(It.IsAny <HttpRequestMessage>())).ReturnsAsync(httpResponseMessage); _invokation = new Mock <IInvocation>(); _invokation.SetupGet(i => i.Method).Returns(typeof(ITestInterface).GetMethod(nameof(ITestInterface.Find))); _invokation.SetupGet(i => i.Arguments).Returns(new object[] { "theType", new TestRequest { Query = "name is SomeValue" } }); _invokation.SetupProperty(i => i.ReturnValue); var interceptor = new WebClientRequestInterceptor <ITestInterface>("http://localhost", _client.Object, new IActionFilter[0]); interceptor.Intercept(_invokation.Object); }