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
90639a7b
Commit
90639a7b
authored
Aug 08, 2009
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code Coverage 88.07%.
parent
ce9ee300
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
57 additions
and
7 deletions
+57
-7
LocalTestRun.testrunconfig
PcapDotNet/src/LocalTestRun.testrunconfig
+0
-1
WiresharkCompareTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkCompareTests.cs
+12
-6
IpV4Tests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IpV4Tests.cs
+22
-0
PacketTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/PacketTests.cs
+23
-0
No files found.
PcapDotNet/src/LocalTestRun.testrunconfig
View file @
90639a7b
...
@@ -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>
...
...
PcapDotNet/src/PcapDotNet.Core.Test/WiresharkCompareTests.cs
View file @
90639a7b
...
@@ -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
++];
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/IpV4Tests.cs
View file @
90639a7b
...
@@ -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
);
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/PacketTests.cs
View file @
90639a7b
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
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