public void CreateNotSupportActionTest() { var factory = new HttpFactory(); Assert.Throws(typeof(ArgumentOutOfRangeException), () => { factory.CreateHttp(HttpRequestActionType.None) .Setup() .SetUrl("http://localhost") .SetContent(""); }); }
/// <summary> /// 执行方法 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="request"></param> /// <returns></returns> public T Execute <T>(IWeiXinRequest <T> request) where T : WeiXinResponse { //获得httpMethodAttribute数据. Type info = request.GetType(); var HttpAttributeInfo = (HttpMethodAttribute)System.Attribute.GetCustomAttribute(info, typeof(HttpMethodAttribute)); ///根据不同的请求方式 Http <T> http = HttpFactory <T> .CreateHttp(HttpAttributeInfo.Method); //延签消息 http.Token = Token; http.HttpMethodAttribute = HttpAttributeInfo; http.Request = request; return(http.GetResponse()); }
public async System.Threading.Tasks.Task CreateHttpActionTestAsync() { var options = new HttpOptions(); options.AddFileExtAsContentType(".txt", "is txt file"); var factory = new HttpFactory(options); var httpGet = factory.CreateHttp(HttpRequestActionType.Get) .Setup() .SetUrl("http://www.baidu.com"); var response = await httpGet.GetResponseAsync(); Assert.NotEmpty(response); }