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
0808ef5b
Commit
0808ef5b
authored
May 19, 2010
by
Brickner_cp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code Coverage 97.91%
parent
0f4c9f93
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
314 additions
and
72 deletions
+314
-72
BerkeleyPacketFilterTests.cs
...Net/src/PcapDotNet.Core.Test/BerkeleyPacketFilterTests.cs
+1
-1
LivePacketDeviceTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/LivePacketDeviceTests.cs
+1
-1
PcapDataLinkTests.cs
PcapDotNet/src/PcapDotNet.Core.Test/PcapDataLinkTests.cs
+1
-1
ArpTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/ArpTests.cs
+18
-2
ByteArrayExtensionsTests.cs
...t/src/PcapDotNet.Packets.Test/ByteArrayExtensionsTests.cs
+99
-0
DatagramTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/DatagramTests.cs
+8
-0
EthernetTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/EthernetTests.cs
+2
-2
GreTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/GreTests.cs
+2
-2
IcmpTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IcmpTests.cs
+14
-0
IgmpTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IgmpTests.cs
+49
-1
IpV4AddressTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IpV4AddressTests.cs
+8
-0
IpV4Tests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IpV4Tests.cs
+48
-55
IpV6AddressTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/IpV6AddressTests.cs
+10
-2
MacAddressTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/MacAddressTests.cs
+9
-1
PacketBuilderTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/PacketBuilderTests.cs
+11
-2
PacketTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/PacketTests.cs
+8
-0
PcapDotNet.Packets.Test.csproj
...rc/PcapDotNet.Packets.Test/PcapDotNet.Packets.Test.csproj
+1
-0
TcpTests.cs
PcapDotNet/src/PcapDotNet.Packets.Test/TcpTests.cs
+23
-1
ArpLayer.cs
PcapDotNet/src/PcapDotNet.Packets/Arp/ArpLayer.cs
+1
-1
No files found.
PcapDotNet/src/PcapDotNet.Core.Test/BerkeleyPacketFilterTests.cs
View file @
0808ef5b
...
@@ -47,7 +47,7 @@ namespace PcapDotNet.Core.Test
...
@@ -47,7 +47,7 @@ namespace PcapDotNet.Core.Test
#
endregion
#
endregion
[
TestMethod
]
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
))]
[
ExpectedException
(
typeof
(
ArgumentException
)
,
AllowDerivedTypes
=
false
)]
public
void
BadFilterErrorTest
()
public
void
BadFilterErrorTest
()
{
{
using
(
PacketCommunicator
communicator
=
LivePacketDeviceTests
.
OpenLiveDevice
())
using
(
PacketCommunicator
communicator
=
LivePacketDeviceTests
.
OpenLiveDevice
())
...
...
PcapDotNet/src/PcapDotNet.Core.Test/LivePacketDeviceTests.cs
View file @
0808ef5b
...
@@ -136,7 +136,7 @@ namespace PcapDotNet.Core.Test
...
@@ -136,7 +136,7 @@ namespace PcapDotNet.Core.Test
// Break loop
// Break loop
TestReceivePackets
(
NumPacketsToSend
,
NumPacketsToSend
,
0
,
2
,
PacketSize
,
PacketCommunicatorReceiveResult
.
BreakLoop
,
0
,
0
,
0.027
);
TestReceivePackets
(
NumPacketsToSend
,
NumPacketsToSend
,
0
,
2
,
PacketSize
,
PacketCommunicatorReceiveResult
.
BreakLoop
,
0
,
0
,
0.027
);
TestReceivePackets
(
NumPacketsToSend
,
NumPacketsToSend
,
NumPacketsToSend
/
2
,
2
,
PacketSize
,
PacketCommunicatorReceiveResult
.
BreakLoop
,
NumPacketsToSend
/
2
,
0
,
0.0
2
);
TestReceivePackets
(
NumPacketsToSend
,
NumPacketsToSend
,
NumPacketsToSend
/
2
,
2
,
PacketSize
,
PacketCommunicatorReceiveResult
.
BreakLoop
,
NumPacketsToSend
/
2
,
0
,
0.0
31
);
}
}
[
TestMethod
]
[
TestMethod
]
...
...
PcapDotNet/src/PcapDotNet.Core.Test/PcapDataLinkTests.cs
View file @
0808ef5b
...
@@ -96,7 +96,7 @@ namespace PcapDotNet.Core.Test
...
@@ -96,7 +96,7 @@ namespace PcapDotNet.Core.Test
}
}
[
TestMethod
]
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
))]
[
ExpectedException
(
typeof
(
ArgumentException
)
,
AllowDerivedTypes
=
false
)]
public
void
InvalidNameErrorTest
()
public
void
InvalidNameErrorTest
()
{
{
PcapDataLink
dataLink
=
new
PcapDataLink
(
"Invalid Name"
);
PcapDataLink
dataLink
=
new
PcapDataLink
(
"Invalid Name"
);
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/ArpTests.cs
View file @
0808ef5b
...
@@ -109,7 +109,7 @@ namespace PcapDotNet.Packets.Test
...
@@ -109,7 +109,7 @@ namespace PcapDotNet.Packets.Test
}
}
[
TestMethod
]
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
))]
[
ExpectedException
(
typeof
(
ArgumentException
)
,
AllowDerivedTypes
=
false
)]
public
void
ArpIncosistentSenderAddressSizeTest
()
public
void
ArpIncosistentSenderAddressSizeTest
()
{
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
...
@@ -131,7 +131,7 @@ namespace PcapDotNet.Packets.Test
...
@@ -131,7 +131,7 @@ namespace PcapDotNet.Packets.Test
}
}
[
TestMethod
]
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
))]
[
ExpectedException
(
typeof
(
ArgumentException
)
,
AllowDerivedTypes
=
false
)]
public
void
ArpIncosistentTargetAddressSizeTest
()
public
void
ArpIncosistentTargetAddressSizeTest
()
{
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
...
@@ -151,5 +151,21 @@ namespace PcapDotNet.Packets.Test
...
@@ -151,5 +151,21 @@ namespace PcapDotNet.Packets.Test
Assert
.
IsNull
(
packet
);
Assert
.
IsNull
(
packet
);
Assert
.
Fail
();
Assert
.
Fail
();
}
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
),
AllowDerivedTypes
=
false
)]
public
void
ArpWriteNullPreviousLayerTest
()
{
new
ArpLayer
().
Write
(
new
byte
[
0
],
0
,
0
,
null
,
new
PayloadLayer
());
Assert
.
Fail
();
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
),
AllowDerivedTypes
=
false
)]
public
void
ArpWriteBadPreviousLayerTest
()
{
new
ArpLayer
().
Write
(
new
byte
[
0
],
0
,
0
,
new
PayloadLayer
(),
new
PayloadLayer
());
Assert
.
Fail
();
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets.Test/ByteArrayExtensionsTests.cs
0 → 100644
View file @
0808ef5b
using
System
;
using
System.Collections.Generic
;
using
Microsoft.VisualStudio.TestTools.UnitTesting
;
namespace
PcapDotNet.Packets.Test
{
/// <summary>
/// Summary description for ByteArrayExtensionsTests
/// </summary>
[
TestClass
]
public
class
ByteArrayExtensionsTests
{
public
ByteArrayExtensionsTests
()
{
//
// TODO: Add constructor logic here
//
}
/// <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
WriteByteNullBufferTest
()
{
ByteArrayExtensions
.
Write
(
null
,
0
,
1
);
Assert
.
Fail
();
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
),
AllowDerivedTypes
=
false
)]
public
void
WriteEnumerableNullBufferTest
()
{
int
offset
=
0
;
ByteArrayExtensions
.
Write
(
null
,
ref
offset
,
new
byte
[
0
]);
Assert
.
Fail
();
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
),
AllowDerivedTypes
=
false
)]
public
void
WriteEnumerableNullEnumerableTest
()
{
int
offset
=
0
;
new
byte
[
0
].
Write
(
ref
offset
,
(
IEnumerable
<
byte
>)
null
);
Assert
.
Fail
();
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
),
AllowDerivedTypes
=
false
)]
public
void
WriteDatagramNullBufferTest
()
{
new
byte
[
0
].
Write
(
0
,
null
);
Assert
.
Fail
();
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
),
AllowDerivedTypes
=
false
)]
public
void
WriteRefDatagramNullBufferTest
()
{
int
offset
=
0
;
new
byte
[
0
].
Write
(
ref
offset
,
null
);
Assert
.
Fail
();
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
),
AllowDerivedTypes
=
false
)]
public
void
ReadByteNullBufferTest
()
{
Assert
.
IsNotNull
(
ByteArrayExtensions
.
ReadByte
(
null
,
0
));
Assert
.
Fail
();
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets.Test/DatagramTests.cs
View file @
0808ef5b
...
@@ -128,5 +128,13 @@ namespace PcapDotNet.Packets.Test
...
@@ -128,5 +128,13 @@ namespace PcapDotNet.Packets.Test
}
}
}
}
}
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
),
AllowDerivedTypes
=
false
)]
public
void
DatagramConstructorNullBufferTest
()
{
Assert
.
IsNotNull
(
new
Datagram
(
null
));
Assert
.
Fail
();
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets.Test/EthernetTests.cs
View file @
0808ef5b
...
@@ -79,7 +79,7 @@ namespace PcapDotNet.Packets.Test
...
@@ -79,7 +79,7 @@ namespace PcapDotNet.Packets.Test
}
}
[
TestMethod
]
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
))]
[
ExpectedException
(
typeof
(
ArgumentException
)
,
AllowDerivedTypes
=
false
)]
public
void
AutomaticEthernetTypeNoNextLayer
()
public
void
AutomaticEthernetTypeNoNextLayer
()
{
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
());
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
());
...
@@ -87,7 +87,7 @@ namespace PcapDotNet.Packets.Test
...
@@ -87,7 +87,7 @@ namespace PcapDotNet.Packets.Test
}
}
[
TestMethod
]
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
))]
[
ExpectedException
(
typeof
(
ArgumentException
)
,
AllowDerivedTypes
=
false
)]
public
void
AutomaticEthernetTypeBadNextLayer
()
public
void
AutomaticEthernetTypeBadNextLayer
()
{
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
TcpLayer
());
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
TcpLayer
());
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/GreTests.cs
View file @
0808ef5b
...
@@ -188,7 +188,7 @@ namespace PcapDotNet.Packets.Test
...
@@ -188,7 +188,7 @@ namespace PcapDotNet.Packets.Test
}
}
[
TestMethod
]
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
))]
[
ExpectedException
(
typeof
(
ArgumentException
)
,
AllowDerivedTypes
=
false
)]
public
void
GreAutomaticProtocolTypeNoNextLayer
()
public
void
GreAutomaticProtocolTypeNoNextLayer
()
{
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV4Layer
(),
new
GreLayer
());
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV4Layer
(),
new
GreLayer
());
...
@@ -196,7 +196,7 @@ namespace PcapDotNet.Packets.Test
...
@@ -196,7 +196,7 @@ namespace PcapDotNet.Packets.Test
}
}
[
TestMethod
]
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
))]
[
ExpectedException
(
typeof
(
ArgumentException
)
,
AllowDerivedTypes
=
false
)]
public
void
GreAutomaticProtocolTypeBadNextLayer
()
public
void
GreAutomaticProtocolTypeBadNextLayer
()
{
{
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV4Layer
(),
new
GreLayer
(),
new
PayloadLayer
());
Packet
packet
=
PacketBuilder
.
Build
(
DateTime
.
Now
,
new
EthernetLayer
(),
new
IpV4Layer
(),
new
GreLayer
(),
new
PayloadLayer
());
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/IcmpTests.cs
View file @
0808ef5b
...
@@ -196,5 +196,19 @@ namespace PcapDotNet.Packets.Test
...
@@ -196,5 +196,19 @@ namespace PcapDotNet.Packets.Test
Assert
.
AreNotEqual
(
entry1
,
entry2
);
Assert
.
AreNotEqual
(
entry1
,
entry2
);
Assert
.
AreNotEqual
(
entry1
.
GetHashCode
(),
entry2
.
GetHashCode
());
Assert
.
AreNotEqual
(
entry1
.
GetHashCode
(),
entry2
.
GetHashCode
());
}
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
),
AllowDerivedTypes
=
false
)]
public
void
IcmpDatagramCreateDatagramNullBufferTest
()
{
Assert
.
IsNotNull
(
IcmpDatagram
.
CreateDatagram
(
null
,
0
,
0
));
Assert
.
Fail
();
}
[
TestMethod
]
public
void
IcmpDatagramCreateDatagramBadOffsetTest
()
{
Assert
.
IsInstanceOfType
(
IcmpDatagram
.
CreateDatagram
(
new
byte
[
0
],
-
1
,
0
),
typeof
(
IcmpUnknownDatagram
));
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets.Test/IgmpTests.cs
View file @
0808ef5b
...
@@ -96,6 +96,46 @@ namespace PcapDotNet.Packets.Test
...
@@ -96,6 +96,46 @@ namespace PcapDotNet.Packets.Test
MoreAssert
.
IsSmallerOrEqual
(
IgmpDatagram
.
MaxMaxResponseTime
,
packet
.
Ethernet
.
IpV4
.
Igmp
.
MaxResponseTime
);
MoreAssert
.
IsSmallerOrEqual
(
IgmpDatagram
.
MaxMaxResponseTime
,
packet
.
Ethernet
.
IpV4
.
Igmp
.
MaxResponseTime
);
if
(
packet
.
Ethernet
.
IpV4
.
Igmp
.
MessageType
!=
IgmpMessageType
.
MembershipQuery
)
if
(
packet
.
Ethernet
.
IpV4
.
Igmp
.
MessageType
!=
IgmpMessageType
.
MembershipQuery
)
Assert
.
AreEqual
(
IgmpQueryVersion
.
None
,
packet
.
Ethernet
.
IpV4
.
Igmp
.
QueryVersion
);
Assert
.
AreEqual
(
IgmpQueryVersion
.
None
,
packet
.
Ethernet
.
IpV4
.
Igmp
.
QueryVersion
);
switch
(
igmpLayer
.
MessageType
)
{
case
IgmpMessageType
.
MembershipQuery
:
switch
(
igmpLayer
.
QueryVersion
)
{
case
IgmpQueryVersion
.
Version1
:
Assert
.
AreEqual
(
1
,
packet
.
Ethernet
.
IpV4
.
Igmp
.
Version
);
break
;
case
IgmpQueryVersion
.
Version2
:
Assert
.
AreEqual
(
2
,
packet
.
Ethernet
.
IpV4
.
Igmp
.
Version
);
break
;
case
IgmpQueryVersion
.
Version3
:
Assert
.
AreEqual
(
3
,
packet
.
Ethernet
.
IpV4
.
Igmp
.
Version
);
break
;
default
:
Assert
.
Fail
(
igmpLayer
.
QueryVersion
.
ToString
());
break
;
}
break
;
case
IgmpMessageType
.
MembershipReportVersion1
:
Assert
.
AreEqual
(
1
,
packet
.
Ethernet
.
IpV4
.
Igmp
.
Version
);
break
;
case
IgmpMessageType
.
MembershipReportVersion2
:
case
IgmpMessageType
.
LeaveGroupVersion2
:
Assert
.
AreEqual
(
2
,
packet
.
Ethernet
.
IpV4
.
Igmp
.
Version
);
break
;
case
IgmpMessageType
.
MembershipReportVersion3
:
Assert
.
AreEqual
(
3
,
packet
.
Ethernet
.
IpV4
.
Igmp
.
Version
);
break
;
default
:
Assert
.
Fail
(
igmpLayer
.
MessageType
.
ToString
());
break
;
}
foreach
(
IgmpGroupRecordDatagram
groupRecord
in
packet
.
Ethernet
.
IpV4
.
Igmp
.
GroupRecords
)
foreach
(
IgmpGroupRecordDatagram
groupRecord
in
packet
.
Ethernet
.
IpV4
.
Igmp
.
GroupRecords
)
Assert
.
IsNotNull
(
groupRecord
.
ToString
());
Assert
.
IsNotNull
(
groupRecord
.
ToString
());
}
}
...
@@ -333,7 +373,7 @@ namespace PcapDotNet.Packets.Test
...
@@ -333,7 +373,7 @@ namespace PcapDotNet.Packets.Test
}
}
[
TestMethod
]
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
))]
[
ExpectedException
(
typeof
(
ArgumentException
)
,
AllowDerivedTypes
=
false
)]
public
void
IgmpGroupRecordBadAuxiliaryDataLengthTest
()
public
void
IgmpGroupRecordBadAuxiliaryDataLengthTest
()
{
{
IgmpGroupRecord
record
=
new
IgmpGroupRecord
(
IgmpRecordType
.
SourceListChangeAllowNewSources
,
IpV4Address
.
Zero
,
new
List
<
IpV4Address
>(),
IgmpGroupRecord
record
=
new
IgmpGroupRecord
(
IgmpRecordType
.
SourceListChangeAllowNewSources
,
IpV4Address
.
Zero
,
new
List
<
IpV4Address
>(),
...
@@ -396,5 +436,13 @@ namespace PcapDotNet.Packets.Test
...
@@ -396,5 +436,13 @@ namespace PcapDotNet.Packets.Test
};
};
Assert
.
IsFalse
(
layer1
.
Equals
(
layer2
));
Assert
.
IsFalse
(
layer1
.
Equals
(
layer2
));
}
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
),
AllowDerivedTypes
=
false
)]
public
void
IgmpGroupRecordConstructorNullTest
()
{
Assert
.
IsNotNull
(
new
IgmpGroupRecord
(
IgmpRecordType
.
FilterModeChangeToExclude
,
IpV4Address
.
Zero
,
new
IpV4Address
[
0
],
null
));
Assert
.
Fail
();
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets.Test/IpV4AddressTests.cs
View file @
0808ef5b
...
@@ -116,5 +116,13 @@ namespace PcapDotNet.Packets.Test
...
@@ -116,5 +116,13 @@ namespace PcapDotNet.Packets.Test
Assert
.
AreNotEqual
(
address
,
buffer
.
ReadIpV4Address
(
0
,
Endianity
.
Big
));
Assert
.
AreNotEqual
(
address
,
buffer
.
ReadIpV4Address
(
0
,
Endianity
.
Big
));
}
}
}
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
),
AllowDerivedTypes
=
false
)]
public
void
IpV4AddressConstructorNullTest
()
{
Assert
.
IsNotNull
(
new
IpV4Address
(
null
));
Assert
.
Fail
();
}
}
}
}
}
PcapDotNet/src/PcapDotNet.Packets.Test/IpV4Tests.cs
View file @
0808ef5b
This diff is collapsed.
Click to expand it.
PcapDotNet/src/PcapDotNet.Packets.Test/IpV6AddressTests.cs
View file @
0808ef5b
...
@@ -155,7 +155,7 @@ namespace PcapDotNet.Packets.Test
...
@@ -155,7 +155,7 @@ namespace PcapDotNet.Packets.Test
}
}
[
TestMethod
]
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
))]
[
ExpectedException
(
typeof
(
ArgumentException
)
,
AllowDerivedTypes
=
false
)]
public
void
IpV6AddressNoColonTest
()
public
void
IpV6AddressNoColonTest
()
{
{
IpV6Address
ipV6Address
=
new
IpV6Address
(
"123"
);
IpV6Address
ipV6Address
=
new
IpV6Address
(
"123"
);
...
@@ -163,11 +163,19 @@ namespace PcapDotNet.Packets.Test
...
@@ -163,11 +163,19 @@ namespace PcapDotNet.Packets.Test
}
}
[
TestMethod
]
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
))]
[
ExpectedException
(
typeof
(
ArgumentException
)
,
AllowDerivedTypes
=
false
)]
public
void
IpV6AddressDoubleColonsWithoutMissingColonsTest
()
public
void
IpV6AddressDoubleColonsWithoutMissingColonsTest
()
{
{
IpV6Address
ipV6Address
=
new
IpV6Address
(
"1::2:3:4:5:6:7:8"
);
IpV6Address
ipV6Address
=
new
IpV6Address
(
"1::2:3:4:5:6:7:8"
);
Assert
.
AreEqual
(
ipV6Address
,
ipV6Address
);
Assert
.
AreEqual
(
ipV6Address
,
ipV6Address
);
}
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
),
AllowDerivedTypes
=
false
)]
public
void
IpV6AddressConstructorNullTest
()
{
Assert
.
IsNotNull
(
new
IpV6Address
(
null
));
Assert
.
Fail
();
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets.Test/MacAddressTests.cs
View file @
0808ef5b
...
@@ -101,12 +101,20 @@ namespace PcapDotNet.Packets.Test
...
@@ -101,12 +101,20 @@ namespace PcapDotNet.Packets.Test
}
}
[
TestMethod
]
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
))]
[
ExpectedException
(
typeof
(
ArgumentException
)
,
AllowDerivedTypes
=
false
)]
public
void
MacAddressBadStringErrorTest
()
public
void
MacAddressBadStringErrorTest
()
{
{
MacAddress
address
=
new
MacAddress
(
"12:34:56:78"
);
MacAddress
address
=
new
MacAddress
(
"12:34:56:78"
);
Assert
.
IsNotNull
(
address
);
Assert
.
IsNotNull
(
address
);
Assert
.
Fail
();
Assert
.
Fail
();
}
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
),
AllowDerivedTypes
=
false
)]
public
void
MacAddressConstructorNullTest
()
{
Assert
.
IsNotNull
(
new
MacAddress
(
null
));
Assert
.
Fail
();
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets.Test/PacketBuilderTests.cs
View file @
0808ef5b
...
@@ -46,7 +46,7 @@ namespace PcapDotNet.Packets.Test
...
@@ -46,7 +46,7 @@ namespace PcapDotNet.Packets.Test
#
endregion
#
endregion
[
TestMethod
]
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
))]
[
ExpectedException
(
typeof
(
ArgumentException
)
,
AllowDerivedTypes
=
false
)]
public
void
NoLayersTest
()
public
void
NoLayersTest
()
{
{
PacketBuilder
packetBuilder
=
new
PacketBuilder
();
PacketBuilder
packetBuilder
=
new
PacketBuilder
();
...
@@ -54,11 +54,20 @@ namespace PcapDotNet.Packets.Test
...
@@ -54,11 +54,20 @@ namespace PcapDotNet.Packets.Test
}
}
[
TestMethod
]
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
))]
[
ExpectedException
(
typeof
(
ArgumentException
)
,
AllowDerivedTypes
=
false
)]
public
void
BadFirstLayerTest
()
public
void
BadFirstLayerTest
()
{
{
PacketBuilder
packetBuilder
=
new
PacketBuilder
(
new
TcpLayer
());
PacketBuilder
packetBuilder
=
new
PacketBuilder
(
new
TcpLayer
());
Assert
.
IsNull
(
packetBuilder
);
Assert
.
IsNull
(
packetBuilder
);
}
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
),
AllowDerivedTypes
=
false
)]
public
void
PacketBuilderConstructorNullTest
()
{
ILayer
[]
layers
=
null
;
Assert
.
IsNotNull
(
new
PacketBuilder
(
layers
));
Assert
.
Fail
();
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets.Test/PacketTests.cs
View file @
0808ef5b
...
@@ -131,5 +131,13 @@ namespace PcapDotNet.Packets.Test
...
@@ -131,5 +131,13 @@ namespace PcapDotNet.Packets.Test
Assert
.
Fail
();
Assert
.
Fail
();
}
}
}
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
),
AllowDerivedTypes
=
false
)]
public
void
PacketFromHexadecimalStringNullTest
()
{
Assert
.
IsNotNull
(
Packet
.
FromHexadecimalString
(
null
,
DateTime
.
MinValue
,
DataLinkKind
.
Ethernet
));
Assert
.
Fail
();
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets.Test/PcapDotNet.Packets.Test.csproj
View file @
0808ef5b
...
@@ -67,6 +67,7 @@
...
@@ -67,6 +67,7 @@
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile
Include=
"ArpTests.cs"
/>
<Compile
Include=
"ArpTests.cs"
/>
<Compile
Include=
"ByteArrayExtensionsTests.cs"
/>
<Compile
Include=
"DatagramTests.cs"
/>
<Compile
Include=
"DatagramTests.cs"
/>
<Compile
Include=
"DataLinkTests.cs"
/>
<Compile
Include=
"DataLinkTests.cs"
/>
<Compile
Include=
"EndianitiyTests.cs"
/>
<Compile
Include=
"EndianitiyTests.cs"
/>
...
...
PcapDotNet/src/PcapDotNet.Packets.Test/TcpTests.cs
View file @
0808ef5b
...
@@ -144,7 +144,7 @@ namespace PcapDotNet.Packets.Test
...
@@ -144,7 +144,7 @@ namespace PcapDotNet.Packets.Test
}
}
[
TestMethod
]
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentException
))]
[
ExpectedException
(
typeof
(
ArgumentException
)
,
AllowDerivedTypes
=
false
)]
public
void
TcpOptionMd5SignatureConstructorErrorDataLengthTest
()
public
void
TcpOptionMd5SignatureConstructorErrorDataLengthTest
()
{
{
new
TcpOptionMd5Signature
(
new
byte
[
10
]);
new
TcpOptionMd5Signature
(
new
byte
[
10
]);
...
@@ -172,5 +172,27 @@ namespace PcapDotNet.Packets.Test
...
@@ -172,5 +172,27 @@ namespace PcapDotNet.Packets.Test
Assert
.
IsFalse
(
packet
.
Ethernet
.
IpV4
.
Tcp
.
Options
.
IsValid
);
Assert
.
IsFalse
(
packet
.
Ethernet
.
IpV4
.
Tcp
.
Options
.
IsValid
);
}
}
[
TestMethod
]
[
ExpectedException
(
typeof
(
ArgumentNullException
),
AllowDerivedTypes
=
false
)]
public
void
TcpOptionMd5SignatureConstructorNullTest
()
{
Assert
.
IsNotNull
(
new
TcpOptionMd5Signature
(
null
));
Assert
.
Fail
();
}
[
TestMethod
]
public
void
TcpOptionCreateInstanceBadValueLengthTest
()
{
int
offset
=
0
;
Assert
.
IsNull
(
new
TcpOptionPartialOrderServiceProfile
().
CreateInstance
(
new
byte
[
0
],
ref
offset
,
123
));
Assert
.
IsNull
(
new
TcpOptionTimestamp
().
CreateInstance
(
new
byte
[
0
],
ref
offset
,
123
));
Assert
.
IsNull
(
new
TcpOptionAlternateChecksumRequest
().
CreateInstance
(
new
byte
[
0
],
ref
offset
,
123
));
Assert
.
IsNull
(
new
TcpOptionConnectionCount
().
CreateInstance
(
new
byte
[
0
],
ref
offset
,
123
));
Assert
.
IsNull
(
new
TcpOptionConnectionCountEcho
().
CreateInstance
(
new
byte
[
0
],
ref
offset
,
123
));
Assert
.
IsNull
(
new
TcpOptionEcho
().
CreateInstance
(
new
byte
[
0
],
ref
offset
,
123
));
Assert
.
IsNull
(
new
TcpOptionSelectiveAcknowledgment
().
CreateInstance
(
new
byte
[
0
],
ref
offset
,
1
));
Assert
.
IsNull
(
new
TcpOptionWindowScale
().
CreateInstance
(
new
byte
[
0
],
ref
offset
,
123
));
}
}
}
}
}
\ No newline at end of file
PcapDotNet/src/PcapDotNet.Packets/Arp/ArpLayer.cs
View file @
0808ef5b
...
@@ -91,7 +91,7 @@ namespace PcapDotNet.Packets.Arp
...
@@ -91,7 +91,7 @@ namespace PcapDotNet.Packets.Arp
public
override
void
Write
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
previousLayer
,
ILayer
nextLayer
)
public
override
void
Write
(
byte
[]
buffer
,
int
offset
,
int
payloadLength
,
ILayer
previousLayer
,
ILayer
nextLayer
)
{
{
if
(
previousLayer
==
null
)
if
(
previousLayer
==
null
)
throw
new
Argument
Exception
(
"Must have a previous l
ayer"
);
throw
new
Argument
NullException
(
"previousL
ayer"
);
IArpPreviousLayer
arpPreviousLayer
=
previousLayer
as
IArpPreviousLayer
;
IArpPreviousLayer
arpPreviousLayer
=
previousLayer
as
IArpPreviousLayer
;
if
(
arpPreviousLayer
==
null
)
if
(
arpPreviousLayer
==
null
)
...
...
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