Commit 89ba2830 authored by Brickner_cp's avatar Brickner_cp

Code Coverage (now with PcapDotNet.Core) 94.15%

parent 07e05ec8
...@@ -112,6 +112,17 @@ namespace PcapDotNet.Core.Test ...@@ -112,6 +112,17 @@ namespace PcapDotNet.Core.Test
} }
} }
[TestMethod]
[ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes = false)]
public void TestNullTest()
{
using (BerkeleyPacketFilter filter = new BerkeleyPacketFilter("ether src 11:22:33:44:55:66", PacketDevice.DefaultSnapshotLength, DataLinkKind.Ethernet))
{
filter.Test(null);
}
Assert.Fail();
}
private static void TestFilter(PacketCommunicator communicator, BerkeleyPacketFilter filter, Packet expectedPacket, Packet unexpectedPacket) private static void TestFilter(PacketCommunicator communicator, BerkeleyPacketFilter filter, Packet expectedPacket, Packet unexpectedPacket)
{ {
communicator.SetFilter(filter); communicator.SetFilter(filter);
......
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Threading; using System.Threading;
using PcapDotNet.Core.Extensions; using PcapDotNet.Core.Extensions;
using PcapDotNet.Packets; using PcapDotNet.Packets;
...@@ -90,6 +91,39 @@ namespace PcapDotNet.Core.Test ...@@ -90,6 +91,39 @@ namespace PcapDotNet.Core.Test
} }
} }
[TestMethod]
[ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes = false)]
public void SendNullPacketTest()
{
using (PacketCommunicator communicator = OpenLiveDevice())
{
communicator.SendPacket(null);
}
Assert.Fail();
}
[TestMethod]
[ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes = false)]
public void SetNullFilterTest()
{
using (PacketCommunicator communicator = OpenLiveDevice())
{
communicator.SetFilter(null as BerkeleyPacketFilter);
}
Assert.Fail();
}
[TestMethod]
[ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes = false)]
public void SetNullSamplingMethodTest()
{
using (PacketCommunicator communicator = OpenLiveDevice())
{
communicator.SetSamplingMethod(null);
}
Assert.Fail();
}
[TestMethod] [TestMethod]
public void ReceiveSomePacketsTest() public void ReceiveSomePacketsTest()
{ {
......
...@@ -68,38 +68,20 @@ namespace PcapDotNet.Core.Test ...@@ -68,38 +68,20 @@ namespace PcapDotNet.Core.Test
} }
} }
// [TestMethod] [TestMethod]
// public void Temp() [ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes = false)]
// { public void SendNullPacketTest()
// EthernetLayer ethernetLayer = new EthernetLayer {
// { PacketDumpFile.Dump(@"dump.pcap", new PcapDataLink(DataLinkKind.Ethernet), PacketDevice.DefaultSnapshotLength, new Packet[1]);
// Source = new MacAddress("00:01:02:03:04:05"), Assert.Fail();
// Destination = new MacAddress("A0:A1:A2:A3:A4:A5") }
// };
// [TestMethod]
// IpV4Layer ipV4Layer = new IpV4Layer [ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes = false)]
// { public void SendNullPacketsTest()
// Source = new IpV4Address("1.2.3.4"), {
// Ttl = 128, PacketDumpFile.Dump(@"dump.pcap", new PcapDataLink(DataLinkKind.Ethernet), PacketDevice.DefaultSnapshotLength, null);
// }; Assert.Fail();
// }
// IcmpEchoLayer icmpLayer = new IcmpEchoLayer();
//
// PacketBuilder builder = new PacketBuilder(ethernetLayer, ipV4Layer, icmpLayer);
//
// List<Packet> packets = new List<Packet>();
//
// for (int i = 0; i != 100; ++i)
// {
// ipV4Layer.Destination = new IpV4Address("2.3.4." + i);
// ipV4Layer.Identification = (ushort)i;
// icmpLayer.SequenceNumber = (ushort)i;
// icmpLayer.Identifier = (ushort)i;
//
// packets.Add(builder.Build(DateTime.Now));
// }
//
// PacketDumpFile.Dump(@"c:\users\boaz\temp.pcap", new PcapDataLink(DataLinkKind.Ethernet), int.MaxValue, packets);
// }
} }
} }
\ No newline at end of file
...@@ -69,6 +69,28 @@ namespace PcapDotNet.Core.Test ...@@ -69,6 +69,28 @@ namespace PcapDotNet.Core.Test
} }
} }
[TestMethod]
[ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes = false)]
public void EnqueueNullTest()
{
using (PacketSendBuffer queue = new PacketSendBuffer(10))
{
queue.Enqueue(null);
}
Assert.Fail();
}
[TestMethod]
[ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes = false)]
public void TransmitNullTest()
{
using (PacketCommunicator communicator = LivePacketDeviceTests.OpenLiveDevice())
{
communicator.Transmit(null, false);
}
Assert.Fail();
}
private static void TestTransmitQueueToLive(int numPacketsToSend, int packetSize, double secondsBetweenTimestamps, bool isSynced) private static void TestTransmitQueueToLive(int numPacketsToSend, int packetSize, double secondsBetweenTimestamps, bool isSynced)
{ {
const string SourceMac = "11:22:33:44:55:66"; const string SourceMac = "11:22:33:44:55:66";
......
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