private static object[] GetURLArguments(MethodInfo method, UriRequest uri) { var methodParams = method.GetParameters(); var args = new Object[methodParams.Count()]; for (var i = 0; i < args.Length; i++){ var param = methodParams[i]; var value = uri.GetParameter(param.Name); if (value == null){ args[i] = param.DefaultValue; } else{ if (param.ParameterType == typeof (int)){ args[i] = int.Parse(value); } else if (param.ParameterType == typeof (string)){ args[i] = value; } else{ args[i] = value; } } } return args; }
public Request(Session session, string uri, string body) { Session = session; Uri = new UriRequest(uri); Body = body; }
public void SlashesAreUsedToDelimateSegments() { var request = new UriRequest("/Hello/World"); request.Segments.Should().BeEquivalentTo("Hello", "World"); }
public void SegmentsAreParsedCorrectly() { var request = new UriRequest("Bomb"); request.Segments.Should().BeEquivalentTo("Bomb"); }
public void ParametersAreParsed() { var request = new UriRequest("/Info?Name=12"); request.GetParameter("Name").Should().Be("12"); request.GetParameter("wowow").Should().BeNull(); }
public void ParametersAreExcludedFromSegments() { var request = new UriRequest("/What/Is?time=0"); request.Segments.Should().BeEquivalentTo("What", "Is"); }
public void CanGetParameter() { var request = new UriRequest("/?name=nick&time=4"); request.GetParameter("name").Should().Be("nick"); request.GetParameter("time").Should().Be("4"); }