static void Main(string[] args) { // Testing Console.WriteLine($"{new string('-', 10)} Test ping {new string('-', 10)}\r\n"); var request = new IcmpRequest(new CmdRequestInfo("www.github.com", "Hello", CmdType.ping, 4, 32, 1000, 1000, 128)); Console.WriteLine($"\r\n\r\n{new string('-', 10)} Test tracert {new string('-', 10)}\r\n"); request = new IcmpRequest(new CmdRequestInfo("www.bmstu.ru", "Hello", CmdType.tracert, 4, 32, 1000, 1000, 128)); Console.WriteLine("\n\nPress any key to exit..."); Console.ReadLine(); }
/// <summary> /// 用于对icmp请求后获取的对象属性进分析,对5条信息 整合成为一条信息 /// </summary> /// <param name="request"></param> /// <returns></returns> public static RequestObj GetProperty(IcmpRequest request) { List <RequestObj> datas = new List <RequestObj>(); datas = request.Requests; RequestObj obj = new RequestObj { TimeCost = 0 }; int count = datas.Count(); for (int i = 0; i < count; i++) { if (obj.Color != null) { if (obj.Color.Equals("2")) { obj.Color = "2"; } else if (obj.Color.Equals("0")) { obj.Color = "0"; } else if (obj.Color.Equals("1")) { obj.Color = "1"; } else { obj.Color = "-1"; } } else { obj.Color = datas[i].Color; } obj.TimeCost = short.Parse((short.Parse(((obj.TimeCost * i) + datas[i].TimeCost).ToString()) / short.Parse((i + 1).ToString())).ToString()); } return(obj); }
public void SetUp() { var mock = new Mock <ILogger <IcmpRequest> >(); _request = new IcmpRequest(mock.Object); }