public void StatusCode() { string testurl = "http://google.co.jp"; Network.Result result = new Network.Result(); Network.Connection con = new Network.Connection(testurl); // 200 test con.GetStatusCode(null, ref result); Assert.AreSame(testurl, result.url); Assert.IsTrue(result.data.Length > 0); Assert.IsNull(result.header); Assert.AreEqual(200, result.returnCode); // 404 test testurl += "/aaaa"; con.ChangeBaseURL(testurl); con.GetStatusCode(null, ref result); Assert.AreSame(testurl, result.url); Assert.IsTrue(result.data.Length > 0); Assert.IsNull(result.header); Assert.AreEqual(404, result.returnCode); // remote名解決エラー testurl = "http://hogehoge"; // 存在しないドメインを指定する con.ChangeBaseURL(testurl); con.GetStatusCode(null, ref result); Assert.AreSame(testurl, result.url); Assert.IsTrue(result.data.Length > 0); Assert.IsNull(result.header); Assert.AreEqual(-1, result.returnCode); }
/// <summary> /// main proc /// </summary> public static int Main(string[] args) { Network.Result result = new Network.Result(); result.returnCode = retParameterIsNotEnough; result.data = strParameterIsNotEnough; if (args.Length >= 1) { Network.Connection con = new Network.Connection(args[0]); con.GetStatusCode(null, ref result); } Console.WriteLine(result.data); return result.returnCode; }