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 void ParametersAreParsed() { var request = new UriRequest("/Info?Name=12"); request.GetParameter("Name").Should().Be("12"); request.GetParameter("wowow").Should().BeNull(); }
public void CanGetParameter() { var request = new UriRequest("/?name=nick&time=4"); request.GetParameter("name").Should().Be("nick"); request.GetParameter("time").Should().Be("4"); }