public void TcpPingerTest() { var testLogger = new TestLogger(); var pinger = new TcpPinger(testLogger); Assert.DoesNotThrow(() => { pinger.Ping("8.8.8.8", 443, 2); }); Assert.DoesNotThrow(() => { pinger.Ping("ya.ru", 443, 2); }); Assert.Throws <Exception>(() => { pinger.Ping("8.8.8.868271", 443, 2); }); }
public void PingTest() { var tcppinger = new TcpPinger(); var actual = new Dictionary <string, string>(); var expected = tcppinger.Ping(rowhosts).Result; actual.Add("https://www.google.com/", "FAILED"); actual.Add("https://www.google1234455435435.com/", "FAILED"); actual.Add("216.58.207.78", "OK"); actual.Add("34.22.1.23", "FAILED"); Assert.AreEqual(expected, actual); }
public void LoggingTest() { var tcppinger = new TcpPinger(); var rowhostskeys = new List <string>(File.ReadAllLines("./Hosts.txt")); foreach (var item in rowhostskeys) { rowhosts.Add(item, item); } var answer = tcppinger.Ping(rowhosts); foreach (var item in answer.Result) { tcppinger.Logging(item.Key, item.Value); } File.Delete(logpath); }