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
981b531d
Commit
981b531d
authored
Sep 06, 2014
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code Coverage 96.19%
parent
953fe462
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
2 deletions
+86
-2
NetworkInterfaceExtensionsTests.cs
...c/PcapDotNet.Core.Test/NetworkInterfaceExtensionsTests.cs
+52
-0
OfflinePacketDeviceTests.cs
...tNet/src/PcapDotNet.Core.Test/OfflinePacketDeviceTests.cs
+15
-2
PcapDotNet.Core.Test.csproj
...tNet/src/PcapDotNet.Core.Test/PcapDotNet.Core.Test.csproj
+1
-0
EthernetTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/EthernetTests.cs
+18
-0
No files found.
PcapDotNet/src/PcapDotNet.Core.Test/NetworkInterfaceExtensionsTests.cs
0 → 100644
View file @
981b531d
using
System
;
using
System.Net.NetworkInformation
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
using
PcapDotNet.Core.Extensions
;
using
PcapDotNet.TestUtils
;
namespace
PcapDotNet.Core.Test
{
/// <summary>
/// Summary description for NetworkInterfaceExtensionsTests.
/// </summary>
[
TestClass
]
public
class
NetworkInterfaceExtensionsTests
{
/// <summary>
/// Gets or sets the test context which provides
/// information about and functionality for the current test run.
/// </summary>
public
TestContext
TestContext
{
get
;
set
;
}
#
region
Additional
test
attributes
//
// You can use the following additional attributes as you write your tests:
//
// Use ClassInitialize to run code before running the first test in the class
// [ClassInitialize()]
// public static void MyClassInitialize(TestContext testContext) { }
//
// Use ClassCleanup to run code after all tests in a class have run
// [ClassCleanup()]
// public static void MyClassCleanup() { }
//
// Use TestInitialize to run code before running each test
// [TestInitialize()]
// public void MyTestInitialize() { }
//
// Use TestCleanup to run code after each test has run
// [TestCleanup()]
// public void MyTestCleanup() { }
//
#
endregion
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
),
AllowDerivedTypes
=
false
)]
public
void
GetLivePacketDeviceNull
()
{
NetworkInterface
networkInterface
=
null
;
Assert
.
IsNull
(
networkInterface
.
GetLivePacketDevice
());
Assert
.
Fail
();
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Core.Test/OfflinePacketDeviceTests.cs
View file @
981b531d
...
...
@@ -316,7 +316,7 @@ namespace PcapDotNet.Core.Test
}
}
Assert
.
IsTrue
(
File
.
Exists
(
DumpFilename
),
"File "
+
DumpFilename
,
" doesn't exist"
);
Assert
.
IsTrue
(
File
.
Exists
(
DumpFilename
),
string
.
Format
(
"File {0} doesn't exist"
,
DumpFilename
)
);
}
// TODO: Add this test once Dumping to files with Unicode filenames is supported. See http://www.winpcap.org/pipermail/winpcap-users/2011-February/004273.html
...
...
@@ -356,7 +356,20 @@ namespace PcapDotNet.Core.Test
}
}
Assert
.
IsTrue
(
File
.
Exists
(
ReadUnicodeFilename
),
"File "
+
ReadUnicodeFilename
,
" doesn't exist"
);
Assert
.
IsTrue
(
File
.
Exists
(
ReadUnicodeFilename
),
string
.
Format
(
"File {0} doesn't exist"
,
ReadUnicodeFilename
));
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
InvalidOperationException
),
AllowDerivedTypes
=
false
)]
public
void
ReadNonExistingUnicodeFilenameTest
()
{
const
string
ReadUnicodeFilename
=
"abc_non_existing_\u00F9_\u05D0\u05D1\u05D2.pcap"
;
OfflinePacketDevice
device
=
new
OfflinePacketDevice
(
ReadUnicodeFilename
);
using
(
PacketCommunicator
communicator
=
device
.
Open
())
{
Assert
.
Fail
();
}
}
private
static
void
TestGetSomePackets
(
int
numPacketsToSend
,
int
numPacketsToGet
,
int
numPacketsToBreakLoop
,
...
...
PcapDotNet/src/PcapDotNet.Core.Test/PcapDotNet.Core.Test.csproj
View file @
981b531d
...
...
@@ -74,6 +74,7 @@
<Compile
Include=
"LivePacketDeviceTests.cs"
/>
<Compile
Include=
"MarshalingServicesTests.cs"
/>
<Compile
Include=
"IpV4OptionExtensions.cs"
/>
<Compile
Include=
"NetworkInterfaceExtensionsTests.cs"
/>
<Compile
Include=
"PacketTimestampTests.cs"
/>
<Compile
Include=
"TcpOptionExtensions.cs"
/>
<Compile
Include=
"WiresharkDatagramComparer.cs"
/>
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/EthernetTests.cs
View file @
981b531d
...
...
@@ -86,5 +86,23 @@ namespace PcapDotNet.Packets.Test
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
TcpLayer
());
Assert
.
IsTrue
(
packet
.
IsValid
);
}
[
TestMethod
]
public
void
NoPayloadByEtherType
()
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
{
EtherType
=
EthernetType
.
AppleTalk
},
new
PayloadLayer
{
Data
=
new
Datagram
(
new
byte
[
100
])
});
Assert
.
IsTrue
(
packet
.
IsValid
);
Assert
.
IsNull
(
packet
.
Ethernet
.
TrailerWithFrameCheckSequence
);
Assert
.
IsNull
(
packet
.
Ethernet
.
Trailer
);
Assert
.
IsNull
(
packet
.
Ethernet
.
FrameCheckSequence
);
}
}
}
\ No newline at end of file
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