private Request BuildHttpRequest() { var methodName = method_selector.SelectedItem.ToString(); var method = MethodResolver.Resolve(methodName); var hostNameEndPos = Regex.Match(address_bar.Text, "/").Index; _hostName = address_bar.Text.Substring(0, hostNameEndPos); _resource = address_bar.Text.Substring(hostNameEndPos, address_bar.Text.Length - hostNameEndPos); var httpRequest = new Request(method, _hostName, _resource); if (Data != null) { httpRequest.Body = Data; httpRequest.AddHeader("Content-Length", Data.Length.ToString()); } else { httpRequest.AddHeader("Content-Length", "0"); } if (Credentials != null) { var authHeader = new AuthHeader(Credentials); httpRequest.AddHeader(authHeader); } if (Headers != null) { httpRequest.AddMultipleHeaders(Headers); } return(httpRequest); }
public void MethodResolver_ResolvesCorrectly() { // Arrange var method = typeof(Counter).GetMethod(nameof(Counter.Increment)); var methodResolver = new MethodResolver(method); var counter = new Counter(); var context = new ResolveFieldContext() { Source = counter }; // Act var result = (int)methodResolver.Resolve(context); // Assert result.ShouldBe(1); counter.Value.ShouldBe(1); }
public void MethodResolver_SupportsEnumArguments() { // Arrange var method = typeof(Counter).GetMethod(nameof(Counter.HasParity)); var methodResolver = new MethodResolver(method, null, new [] { new QueryArgumentParameterInfo(method.GetParameters()[0]) }); var counter = new Counter { Value = 6 }; var context = new ResolveFieldContext { Source = counter, Arguments = new Dictionary <string, object> { { "parity", Parity.Even } } }; // Act var result = (bool)methodResolver.Resolve(context); // Assert result.ShouldBe(true); }