Commit 87cc08fe authored by Brickner_cp's avatar Brickner_cp

refactoring

parent 7c8be298
...@@ -55,6 +55,7 @@ namespace PcapDotNet.Base.Test ...@@ -55,6 +55,7 @@ namespace PcapDotNet.Base.Test
UInt128 value = random.NextUInt128(); UInt128 value = random.NextUInt128();
Assert.AreEqual(value, value); Assert.AreEqual(value, value);
Assert.AreNotEqual(value, string.Empty);
Assert.IsTrue(value == value); Assert.IsTrue(value == value);
Assert.IsFalse(value != value); Assert.IsFalse(value != value);
Assert.IsNotNull(value.GetHashCode()); Assert.IsNotNull(value.GetHashCode());
......
...@@ -87,41 +87,6 @@ namespace PcapDotNet.Base.Test ...@@ -87,41 +87,6 @@ namespace PcapDotNet.Base.Test
Assert.IsNotNull(value); Assert.IsNotNull(value);
} }
// [TestMethod]
// public void UInt48Test()
// {
// UInt48 value = (UInt48)0x010203040506;
// byte[] buffer = new byte[UInt48.SizeOf];
//
// buffer.Write(0, value, Endianity.Big);
// Assert.AreEqual(value, buffer.ReadUInt48(0, Endianity.Big));
// Assert.AreEqual(0x01, buffer[0]);
// Assert.AreEqual(0x02, buffer[1]);
// Assert.AreEqual(0x03, buffer[2]);
// Assert.AreEqual(0x04, buffer[3]);
// Assert.AreEqual(0x05, buffer[4]);
// Assert.AreEqual(0x06, buffer[5]);
//
// int offset = 0;
// buffer.Write(ref offset, value, Endianity.Big);
// Assert.AreEqual(value, buffer.ReadUInt48(0, Endianity.Big));
// Assert.AreEqual(6, offset);
//
// buffer.Write(0, value, Endianity.Small);
// Assert.AreEqual(value, buffer.ReadUInt48(0, Endianity.Small));
// Assert.AreEqual(0x06, buffer[0]);
// Assert.AreEqual(0x05, buffer[1]);
// Assert.AreEqual(0x04, buffer[2]);
// Assert.AreEqual(0x03, buffer[3]);
// Assert.AreEqual(0x02, buffer[4]);
// Assert.AreEqual(0x01, buffer[5]);
//
// offset = 0;
// buffer.Write(ref offset, value, Endianity.Small);
// Assert.AreEqual(value, buffer.ReadUInt48(0, Endianity.Small));
// Assert.AreEqual(6, offset);
// }
[TestMethod] [TestMethod]
public void UInt48Test() public void UInt48Test()
{ {
......
...@@ -152,7 +152,7 @@ namespace PcapDotNet.Core.Test ...@@ -152,7 +152,7 @@ namespace PcapDotNet.Core.Test
TestReceivePacketsEnumerable(NumPacketsToSend, NumPacketsToSend / 2, int.MaxValue, 2, PacketSize, NumPacketsToSend / 2, 0, 0.027); TestReceivePacketsEnumerable(NumPacketsToSend, NumPacketsToSend / 2, int.MaxValue, 2, PacketSize, NumPacketsToSend / 2, 0, 0.027);
// Wait for more packets // Wait for more packets
TestReceivePacketsEnumerable(NumPacketsToSend, -1, int.MaxValue, 2, PacketSize, NumPacketsToSend, 2, 2.02); TestReceivePacketsEnumerable(NumPacketsToSend, -1, int.MaxValue, 2, PacketSize, NumPacketsToSend, 2, 2.021);
TestReceivePacketsEnumerable(NumPacketsToSend, NumPacketsToSend + 1, int.MaxValue, 2, PacketSize, NumPacketsToSend, 2, 2.13); TestReceivePacketsEnumerable(NumPacketsToSend, NumPacketsToSend + 1, int.MaxValue, 2, PacketSize, NumPacketsToSend, 2, 2.13);
// Break loop // Break loop
......
...@@ -81,6 +81,41 @@ namespace PcapDotNet.Packets.Test ...@@ -81,6 +81,41 @@ namespace PcapDotNet.Packets.Test
Assert.AreEqual(3, offset); Assert.AreEqual(3, offset);
} }
[TestMethod]
public void UInt48Test()
{
UInt48 value = (UInt48)0x010203040506;
byte[] buffer = new byte[UInt48.SizeOf];
buffer.Write(0, value, Endianity.Big);
Assert.AreEqual(value, buffer.ReadUInt48(0, Endianity.Big));
Assert.AreEqual(0x01, buffer[0]);
Assert.AreEqual(0x02, buffer[1]);
Assert.AreEqual(0x03, buffer[2]);
Assert.AreEqual(0x04, buffer[3]);
Assert.AreEqual(0x05, buffer[4]);
Assert.AreEqual(0x06, buffer[5]);
int offset = 0;
buffer.Write(ref offset, value, Endianity.Big);
Assert.AreEqual(value, buffer.ReadUInt48(0, Endianity.Big));
Assert.AreEqual(6, offset);
buffer.Write(0, value, Endianity.Small);
Assert.AreEqual(value, buffer.ReadUInt48(0, Endianity.Small));
Assert.AreEqual(0x06, buffer[0]);
Assert.AreEqual(0x05, buffer[1]);
Assert.AreEqual(0x04, buffer[2]);
Assert.AreEqual(0x03, buffer[3]);
Assert.AreEqual(0x02, buffer[4]);
Assert.AreEqual(0x01, buffer[5]);
offset = 0;
buffer.Write(ref offset, value, Endianity.Small);
Assert.AreEqual(value, buffer.ReadUInt48(0, Endianity.Small));
Assert.AreEqual(6, offset);
}
[TestMethod] [TestMethod]
public void UIntTest() public void UIntTest()
{ {
......
...@@ -12,7 +12,7 @@ namespace PcapDotNet.Packets ...@@ -12,7 +12,7 @@ namespace PcapDotNet.Packets
/// <summary> /// <summary>
/// Extension methods for byte[]. /// Extension methods for byte[].
/// </summary> /// </summary>
public static class MoreByteArray public static class ByteArrayExtensions
{ {
/// <summary> /// <summary>
/// Copies a specified number of bytes from a source array starting at a particular offset to a destination array starting at a particular offset. /// Copies a specified number of bytes from a source array starting at a particular offset to a destination array starting at a particular offset.
......
...@@ -195,7 +195,7 @@ ...@@ -195,7 +195,7 @@
<Compile Include="IpV4\IpV4OptionTraceRoute.cs" /> <Compile Include="IpV4\IpV4OptionTraceRoute.cs" />
<Compile Include="IpV4\IpV4OptionType.cs" /> <Compile Include="IpV4\IpV4OptionType.cs" />
<Compile Include="IpV4\IpV4Protocol.cs" /> <Compile Include="IpV4\IpV4Protocol.cs" />
<Compile Include="MoreByteArray.cs" /> <Compile Include="ByteArrayExtensions.cs" />
<Compile Include="OptionComplexFactory.cs" /> <Compile Include="OptionComplexFactory.cs" />
<Compile Include="OptionComplexFactoryBase.cs" /> <Compile Include="OptionComplexFactoryBase.cs" />
<Compile Include="Options.cs" /> <Compile Include="Options.cs" />
......
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