Commit a1f5d127 authored by Boaz Brickner's avatar Boaz Brickner

More detailed exceptions for Wireshark compare tests.

parent d103f0f6
...@@ -82,14 +82,36 @@ namespace PcapDotNet.Core.Test ...@@ -82,14 +82,36 @@ namespace PcapDotNet.Core.Test
Console.WriteLine("Seed: " + seed); Console.WriteLine("Seed: " + seed);
Random random = new Random(seed); Random random = new Random(seed);
try
{
for (int i = 0; i != 10; ++i) for (int i = 0; i != 10; ++i)
{
List<Packet> packets;
try
{ {
// Create packets // Create packets
List<Packet> packets = new List<Packet>(CreateRandomPackets(random, 200)); packets = new List<Packet>(CreateRandomPackets(random, 200));
}
catch (Exception exception)
{
throw new AssertFailedException("Failed creating packets. " + exception, exception);
}
try
{
// Compare packets to wireshark // Compare packets to wireshark
ComparePacketsToWireshark(packets); ComparePacketsToWireshark(packets);
} }
catch (Exception exception)
{
throw new AssertFailedException("Failed comparing packets. " + exception, exception);
}
}
}
catch (Exception exception)
{
throw new AssertFailedException("Failed test with seed " + seed + ". " + exception, exception);
}
} }
[TestMethod] [TestMethod]
...@@ -102,7 +124,7 @@ namespace PcapDotNet.Core.Test ...@@ -102,7 +124,7 @@ namespace PcapDotNet.Core.Test
Packet packet = new Packet(new byte[14], timestamp, DataLinkKind.Ethernet); Packet packet = new Packet(new byte[14], timestamp, DataLinkKind.Ethernet);
// Compare packet to wireshark // Compare packet to wireshark
ComparePacketsToWireshark(new[] { packet }); ComparePacketsToWireshark(packet);
// BUG: Limited timestamp due to Windows bug: https://connect.microsoft.com/VisualStudio/feedback/details/559198/net-4-datetime-tolocaltime-is-sometimes-wrong // BUG: Limited timestamp due to Windows bug: https://connect.microsoft.com/VisualStudio/feedback/details/559198/net-4-datetime-tolocaltime-is-sometimes-wrong
// Now check different dates. // Now check different dates.
...@@ -495,9 +517,9 @@ namespace PcapDotNet.Core.Test ...@@ -495,9 +517,9 @@ namespace PcapDotNet.Core.Test
{ {
Compare(XDocument.Load(fixedDocumentFilename, LoadOptions.None), packets); Compare(XDocument.Load(fixedDocumentFilename, LoadOptions.None), packets);
} }
catch (AssertFailedException exception) catch (Exception exception)
{ {
throw new AssertFailedException("Failed comparing packets in file " + pcapFilename + ". Message: " + exception.Message, exception); throw new AssertFailedException("Failed comparing packets in file " + pcapFilename + ". " + exception, exception);
} }
} }
......
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