Ejemplo n.º 1
0
 public async Task StartStopTest()
 {
     await new TaskFactory().StartNew(
         () => {
         var monitor = new NetMonitor();
         monitor.Start();
         monitor.Stop();
     }
         );
 }
Ejemplo n.º 2
0
        public async Task DataLengthTest_FilterString_ExpectPacketReceived()
        {
            var receivedBytes = await new TaskFactory().StartNew(
                () => {
                var monitor = new NetMonitor("dst host " + PING_IP);
                monitor.Start();

                Ping(PING_IP);
                Thread.Sleep(1000);

                monitor.Stop();
                return(monitor.ReceivedBytes);
            }
                );

            Assert.True(receivedBytes > 0);
        }
Ejemplo n.º 3
0
        public async Task DataLengthTest_FilterBuilder_ExpectPacketReceived()
        {
            var pingIp        = IPAddress.Parse(PING_IP);
            var filterBuilder = new PcapFilterBuilder()
                                .AppendIpDst(pingIp);

            var receivedBytes = await new TaskFactory().StartNew(
                () => {
                var monitor = new NetMonitor(filterBuilder);
                monitor.Start();

                Ping(PING_IP);
                Thread.Sleep(1000);

                monitor.Stop();
                return(monitor.ReceivedBytes);
            }
                );

            Assert.True(receivedBytes > 0);
        }