Commit 62def0bc authored by Brickner_cp's avatar Brickner_cp

Code coverage 94.42%

parent 74bbb693
......@@ -153,6 +153,17 @@ namespace PcapDotNet.Core.Test
using (new OfflinePacketDevice("myinvalidfile").Open())
{
}
Assert.Fail();
}
[TestMethod]
[ExpectedException(typeof(InvalidOperationException))]
public void OpenNullFilenameTest()
{
using (new OfflinePacketDevice(null).Open())
{
}
Assert.Fail();
}
[TestMethod]
......
......@@ -245,6 +245,7 @@ namespace PcapDotNet.Packets.Test
Assert.IsTrue(resourceData.IsTypePresentForOwner(DnsType.A));
Assert.IsTrue(resourceData.IsTypePresentForOwner(DnsType.Aaaa));
Assert.IsFalse(resourceData.IsTypePresentForOwner(DnsType.Ns));
Assert.IsFalse(resourceData.IsTypePresentForOwner(DnsType.UInfo));
bitmap = DnsResourceDataNextDomain.CreateTypeBitmap(new DnsType[] { 0 });
Assert.AreEqual(DataSegment.Empty, bitmap);
......@@ -279,6 +280,34 @@ namespace PcapDotNet.Packets.Test
Assert.Fail();
}
[TestMethod]
public void DnsResourceDataNextDomainParseWrongLengthTest()
{
var resourceData = new DnsResourceDataNextDomain(new DnsDomainName("pcapdot.net"),
DnsResourceDataNextDomain.CreateTypeBitmap(new[] {DnsType.A, DnsType.A6}));
TestResourceRecordIsNotCreatedWithNewLength(DnsType.NextDomain, resourceData, 1);
TestResourceRecordIsNotCreatedWithNewLength(DnsType.NextDomain, resourceData, 12);
TestResourceRecordIsNotCreatedWithNewLength(DnsType.NextDomain, resourceData, -6);
}
[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
public void DnsResourceDataNextDomainConstructorNullTypeBitmapTest()
{
var resourceData = new DnsResourceDataNextDomain(DnsDomainName.Root, null);
Assert.IsNull(resourceData);
Assert.Fail();
}
[TestMethod]
[ExpectedException(typeof(ArgumentNullException))]
public void DnsResourceDataNextDomainCreateTypeBitmapNullInputTest()
{
var bitmap = DnsResourceDataNextDomain.CreateTypeBitmap(null);
Assert.IsNull(bitmap);
Assert.Fail();
}
[TestMethod]
public void DnsResourceDataNamingAuthorityPointerTest()
{
......@@ -637,6 +666,14 @@ namespace PcapDotNet.Packets.Test
TestResourceRecordIsNotCreatedWithNewLength(DnsType.A6, resourceData, -17);
}
[TestMethod]
public void DnsResourceDataAddressPrefixListParseWrongLengthTest()
{
var resourceData = new DnsResourceDataAddressPrefixList(new DnsAddressPrefix(AddressFamily.IpV4, 0, false, new DataSegment(new byte[5])));
TestResourceRecordIsNotCreatedWithNewLength(DnsType.Apl, resourceData, 1);
TestResourceRecordIsNotCreatedWithNewLength(DnsType.Apl, resourceData, -1);
}
private static void TestDomainNameCompression(int expectedCompressionBenefit, DnsLayer dnsLayer)
{
dnsLayer.DomainNameCompressionMode = DnsDomainNameCompressionMode.Nothing;
......
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