Commit b6098579 authored by Brickner_cp's avatar Brickner_cp

Code coverage 95.84%

parent 7a3ec961
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Packets.Ethernet;
using PcapDotNet.Packets.IpV4;
......@@ -158,6 +160,31 @@ namespace PcapDotNet.Packets.Test
}
}
[TestMethod]
public void IpV4NullOptionsTest()
{
Packet packet = PacketBuilder.Build(DateTime.Now,
new IpV4Layer
{
CurrentDestination = new IpV4Address("2.3.4.5"),
Options = new IpV4Options(new IpV4OptionStrictSourceRouting(new[] {new IpV4Address("1.2.3.4")}, 0)),
Protocol = IpV4Protocol.Emcon,
});
Assert.IsTrue(packet.IsValid);
Assert.IsNotNull(packet.IpV4.Options);
Assert.AreEqual(new IpV4Address("1.2.3.4"), packet.IpV4.Destination);
const int newPacketLength = IpV4Datagram.HeaderMinimumLength - 1;
byte[] newPacketBuffer = new byte[newPacketLength];
packet.Take(newPacketLength).ToArray().CopyTo(newPacketBuffer, 0);
Packet newPacket = new Packet(newPacketBuffer, DateTime.Now, DataLinkKind.IpV4);
Assert.IsFalse(newPacket.IsValid);
Assert.IsNull(newPacket.IpV4.Options);
Assert.AreNotEqual(new IpV4Address("1.2.3.4"), newPacket.IpV4.Destination);
}
[TestMethod]
[ExpectedException(typeof(ArgumentOutOfRangeException), AllowDerivedTypes = false)]
public void IpV4OptionTimestampOverflowErrorTest()
......
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