Commit 889a9ec6 authored by Brickner_cp's avatar Brickner_cp

Improved SetSamplingMethodFirstAfterIntervalTest test

parent 1d6bf681
......@@ -528,21 +528,21 @@ namespace PcapDotNet.Core.Test
[TestMethod]
public void SetSamplingMethodFirstAfterIntervalTest()
{
Thread.Sleep(TimeSpan.FromSeconds(2));
Random random = new Random();
const string SourceMac = "11:22:33:44:55:66";
const string DestinationMac = "77:88:99:AA:BB:CC";
MacAddress sourceMac = random.NextMacAddress();
MacAddress destinationMac = random.NextMacAddress();
using (PacketCommunicator communicator = OpenLiveDevice())
{
communicator.SetFilter("ether src " + SourceMac + " and ether dst " + DestinationMac);
communicator.SetFilter("ether src " + sourceMac + " and ether dst " + destinationMac);
communicator.SetSamplingMethod(new SamplingMethodFirstAfterInterval(TimeSpan.FromSeconds(1)));
Packet expectedPacket = _random.NextEthernetPacket(60, SourceMac, DestinationMac);
Packet expectedPacket = _random.NextEthernetPacket(60, sourceMac, destinationMac);
communicator.SendPacket(expectedPacket);
Thread.Sleep(TimeSpan.FromSeconds(0.75));
for (int i = 0; i != 10; ++i)
{
expectedPacket = _random.NextEthernetPacket(60 * (i + 2), SourceMac, DestinationMac);
expectedPacket = _random.NextEthernetPacket(60 * (i + 2), sourceMac, destinationMac);
communicator.SendPacket(expectedPacket);
Thread.Sleep(TimeSpan.FromSeconds(0.5));
}
......
......@@ -91,6 +91,11 @@ namespace PcapDotNet.Packets.TestUtils
return random.NextEthernetPacket(packetSize, timestamp, new MacAddress(ethernetSource), new MacAddress(ethernetDestination));
}
public static Packet NextEthernetPacket(this Random random, int packetSize, MacAddress ethernetSource, MacAddress ethernetDestination)
{
return random.NextEthernetPacket(packetSize, DateTime.Now, ethernetSource, ethernetDestination);
}
public static Packet NextEthernetPacket(this Random random, int packetSize, string ethernetSource, string ethernetDestination)
{
return random.NextEthernetPacket(packetSize, DateTime.Now, ethernetSource, ethernetDestination);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment