Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pcap-Net
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Pcap-Net
Commits
89ba2830
Commit
89ba2830
authored
May 21, 2010
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code Coverage (now with PcapDotNet.Core) 94.15%
parent
07e05ec8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
82 additions
and
33 deletions
+82
-33
BerkeleyPacketFilterTests.cs
...Net/src/PcapDotNet.Core.Test/BerkeleyPacketFilterTests.cs
+11
-0
LivePacketDeviceTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/LivePacketDeviceTests.cs
+34
-0
PacketDumpFileTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/PacketDumpFileTests.cs
+15
-33
PacketSendBufferTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/PacketSendBufferTests.cs
+22
-0
No files found.
PcapDotNet/src/PcapDotNet.Core.Test/BerkeleyPacketFilterTests.cs
View file @
89ba2830
...
...
@@ -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
)
{
communicator
.
SetFilter
(
filter
);
...
...
PcapDotNet/src/PcapDotNet.Core.Test/LivePacketDeviceTests.cs
View file @
89ba2830
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Threading
;
using
PcapDotNet.Core.Extensions
;
using
PcapDotNet.Packets
;
...
...
@@ -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
]
public
void
ReceiveSomePacketsTest
()
{
...
...
PcapDotNet/src/PcapDotNet.Core.Test/PacketDumpFileTests.cs
View file @
89ba2830
...
...
@@ -68,38 +68,20 @@ namespace PcapDotNet.Core.Test
}
}
// [TestMethod]
// public void Temp()
// {
// EthernetLayer ethernetLayer = new EthernetLayer
// {
// Source = new MacAddress("00:01:02:03:04:05"),
// Destination = new MacAddress("A0:A1:A2:A3:A4:A5")
// };
//
// IpV4Layer ipV4Layer = new IpV4Layer
// {
// Source = new IpV4Address("1.2.3.4"),
// Ttl = 128,
// };
//
// 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);
// }
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
),
AllowDerivedTypes
=
false
)]
public
void
SendNullPacketTest
()
{
PacketDumpFile
.
Dump
(
@"dump.pcap"
,
new
PcapDataLink
(
DataLinkKind
.
Ethernet
),
PacketDevice
.
DefaultSnapshotLength
,
new
Packet
[
1
]);
Assert
.
Fail
();
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
),
AllowDerivedTypes
=
false
)]
public
void
SendNullPacketsTest
()
{
PacketDumpFile
.
Dump
(
@"dump.pcap"
,
new
PcapDataLink
(
DataLinkKind
.
Ethernet
),
PacketDevice
.
DefaultSnapshotLength
,
null
);
Assert
.
Fail
();
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Core.Test/PacketSendBufferTests.cs
View file @
89ba2830
...
...
@@ -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
)
{
const
string
SourceMac
=
"11:22:33:44:55:66"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment