Exemplo n.º 1
0
        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); });
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }