Commit 90639a7b authored by Brickner_cp's avatar Brickner_cp

Code Coverage 88.07%.

parent ce9ee300
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
<CodeCoverageItem binaryFile="C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Base.dll" pdbFile="C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Base.pdb" instrumentInPlace="true" /> <CodeCoverageItem binaryFile="C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Base.dll" pdbFile="C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Base.pdb" instrumentInPlace="true" />
<CodeCoverageItem binaryFile="c:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Core.dll" pdbFile="c:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Core.pdb" instrumentInPlace="true" /> <CodeCoverageItem binaryFile="c:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Core.dll" pdbFile="c:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Core.pdb" instrumentInPlace="true" />
<CodeCoverageItem binaryFile="C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Packets.dll" pdbFile="C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Packets.pdb" instrumentInPlace="true" /> <CodeCoverageItem binaryFile="C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Packets.dll" pdbFile="C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Packets.pdb" instrumentInPlace="true" />
<CodeCoverageItem binaryFile="C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Core.Test.dll" pdbFile="C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Core.Test.pdb" instrumentInPlace="true" />
</Regular> </Regular>
</CodeCoverage> </CodeCoverage>
<TestTypeSpecific> <TestTypeSpecific>
......
...@@ -75,11 +75,14 @@ namespace PcapDotNet.Core.Test ...@@ -75,11 +75,14 @@ namespace PcapDotNet.Core.Test
[TestMethod] [TestMethod]
public void ComparePacketsToWiresharkTest() public void ComparePacketsToWiresharkTest()
{ {
// Create packets for (int i = 0; i != 1; ++i)
List<Packet> packets = new List<Packet>(CreateRandomPackets(1000)); {
// Create packets
List<Packet> packets = new List<Packet>(CreateRandomPackets(100));
// Create pcap file // Create pcap file
ComparePacketsToWireshark(packets); ComparePacketsToWireshark(packets);
}
} }
private static IEnumerable<Packet> CreateRandomPackets(int numPackets) private static IEnumerable<Packet> CreateRandomPackets(int numPackets)
...@@ -122,7 +125,8 @@ namespace PcapDotNet.Core.Test ...@@ -122,7 +125,8 @@ namespace PcapDotNet.Core.Test
Arguments = " -t r -n -r \"" + pcapFilename + "\" -T pdml", Arguments = " -t r -n -r \"" + pcapFilename + "\" -T pdml",
WorkingDirectory = WiresharkDiretory, WorkingDirectory = WiresharkDiretory,
UseShellExecute = false, UseShellExecute = false,
RedirectStandardOutput = true RedirectStandardOutput = true,
CreateNoWindow = true
}; };
Console.WriteLine("Starting process " + process.StartInfo.FileName + " " + process.StartInfo.Arguments); Console.WriteLine("Starting process " + process.StartInfo.FileName + " " + process.StartInfo.Arguments);
process.Start(); process.Start();
...@@ -298,7 +302,9 @@ namespace PcapDotNet.Core.Test ...@@ -298,7 +302,9 @@ namespace PcapDotNet.Core.Test
if (currentOptionIndex >= options.Count) if (currentOptionIndex >= options.Count)
{ {
Assert.IsFalse(options.IsValid); Assert.IsFalse(options.IsValid);
Assert.IsTrue(field.Show().StartsWith("Unknown") || field.Show().Contains("with too")); Assert.IsTrue(field.Show().StartsWith("Unknown") ||
field.Show().Contains("with too") ||
field.Show().Contains(" bytes says option goes past end of options"), field.Show());
break; break;
} }
IpV4Option option = options[currentOptionIndex++]; IpV4Option option = options[currentOptionIndex++];
......
...@@ -244,6 +244,28 @@ namespace PcapDotNet.Packets.Test ...@@ -244,6 +244,28 @@ namespace PcapDotNet.Packets.Test
Assert.Fail(); Assert.Fail();
} }
[TestMethod]
public void IpV4OptionTimeOfDayTest()
{
TimeSpan timeOfDay = new TimeSpan(1, 2, 3);
IpV4OptionTimeOfDay timeSinceMidnight = new IpV4OptionTimeOfDay(timeOfDay);
Assert.AreEqual(timeOfDay, timeSinceMidnight.TimeSinceMidnightUniversalTime);
Assert.IsTrue(timeOfDay == timeSinceMidnight.TimeSinceMidnightUniversalTime);
Assert.IsFalse(timeOfDay != timeSinceMidnight.TimeSinceMidnightUniversalTime);
}
[TestMethod]
public void IpV4OptionTimedAddressTest()
{
IpV4OptionTimedAddress timedAddress1 = new IpV4OptionTimedAddress(new IpV4Address("1.2.3.4"), new IpV4OptionTimeOfDay(new TimeSpan(1, 2, 3)));
IpV4OptionTimedAddress timedAddress2 = new IpV4OptionTimedAddress(new IpV4Address("1.2.3.4"), new IpV4OptionTimeOfDay(new TimeSpan(1, 2, 3)));
Assert.AreEqual(timedAddress1, timedAddress2);
Assert.IsTrue(timedAddress1 == timedAddress2);
Assert.IsFalse(timedAddress1 != timedAddress2);
}
private static Packet HexToPacket(string hexString, DataLinkKind dataLinkKind) private static Packet HexToPacket(string hexString, DataLinkKind dataLinkKind)
{ {
return HexToPacket(hexString, DateTime.MinValue, dataLinkKind); return HexToPacket(hexString, DateTime.MinValue, dataLinkKind);
......
using System; using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets.TestUtils; using PcapDotNet.Packets.TestUtils;
...@@ -84,5 +86,26 @@ namespace PcapDotNet.Packets.Test ...@@ -84,5 +86,26 @@ namespace PcapDotNet.Packets.Test
Assert.IsFalse(new Packet(packet.Buffer, DateTime.Now, (DataLinkKind)((int)DataLinkKind.Ethernet + 1)).IsValid); Assert.IsFalse(new Packet(packet.Buffer, DateTime.Now, (DataLinkKind)((int)DataLinkKind.Ethernet + 1)).IsValid);
} }
} }
[TestMethod]
public void PacketIListTest()
{
byte[] buffer = new byte[]{1,2,3,4,5};
IList<byte> packet = new Packet(buffer, DateTime.Now, DataLinkKind.Ethernet);
Assert.IsTrue(packet.Contains(1));
buffer = new byte[buffer.Length];
packet.CopyTo(buffer, 0);
packet.SequenceEqual(buffer);
Assert.AreEqual(1, packet.IndexOf(2));
Assert.AreEqual(buffer.Length, packet.Count);
Assert.AreEqual(buffer[2], packet[2]);
Assert.IsTrue(packet.IsReadOnly);
}
} }
} }
\ No newline at end of file
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