Commit 9b9d4299 authored by Brickner_cp's avatar Brickner_cp

Code Coverage 98.02%

parent 28625c92
<?xml version="1.0" encoding="utf-8"?>
<TestRunConfiguration name="Local Test Run" id="be17286c-6d1c-43dd-b068-e83867abf9c5" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<?xml version="1.0" encoding="UTF-8"?>
<TestSettings name="Local Test Run" id="be17286c-6d1c-43dd-b068-e83867abf9c5" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010">
<Description>This is a default test run configuration for a local test run.</Description>
<CodeCoverage enabled="true" keyFile="PcapDotNet.snk">
<Regular>
<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.Extensions.dll" pdbFile="C:\TFS\tfs06.codeplex.com\PcapDotNet\PcapDotNet\bin\Debug\PcapDotNet.Core.Extensions.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" />
</Regular>
</CodeCoverage>
<TestTypeSpecific>
<WebTestRunConfiguration testTypeId="4e7599fa-5ecb-43e9-a887-cd63cf72d207">
<Browser name="Internet Explorer 7.0">
<Headers>
<Header name="User-Agent" value="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)" />
<Header name="Accept" value="*/*" />
<Header name="Accept-Language" value="{{$IEAcceptLanguage}}" />
<Header name="Accept-Encoding" value="GZIP" />
</Headers>
</Browser>
<Network Name="LAN" BandwidthInKbps="0" />
</WebTestRunConfiguration>
</TestTypeSpecific>
</TestRunConfiguration>
\ No newline at end of file
<Execution>
<TestTypeSpecific>
<WebTestRunConfiguration testTypeId="4e7599fa-5ecb-43e9-a887-cd63cf72d207">
<Browser name="Internet Explorer 7.0">
<Headers>
<Header name="User-Agent" value="Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)" />
<Header name="Accept" value="*/*" />
<Header name="Accept-Language" value="{{$IEAcceptLanguage}}" />
<Header name="Accept-Encoding" value="GZIP" />
</Headers>
</Browser>
</WebTestRunConfiguration>
<UnitTestRunConfig testTypeId="13cdc9d9-ddb5-4fa4-a97d-d965ccfc6d4b">
<AssemblyResolution>
<TestDirectory useLoadContext="true" />
</AssemblyResolution>
</UnitTestRunConfig>
</TestTypeSpecific>
<AgentRule name="LocalMachineDefaultRole">
<DataCollectors>
<DataCollector uri="datacollector://Microsoft/CodeCoverage/1.0" assemblyQualifiedName="Microsoft.VisualStudio.TestTools.CodeCoverage.CoveragePlugIn, Microsoft.VisualStudio.QualityTools.Plugins.CodeCoverage, PublicKeyToken=b03f5f7f11d50a3a">
<Configuration>
<CodeCoverage keyFile="PcapDotNet.snk" xmlns="">
<Regular>
<CodeCoverageItem binaryFile="..\bin\Release\PcapDotNet.Core.dll" pdbFile="..\bin\Release\PcapDotNet.Core.pdb" instrumentInPlace="true">
<KeyFile path="PcapDotNet.snk" />
</CodeCoverageItem>
<CodeCoverageItem binaryFile="..\bin\Release\PcapDotNet.Core.Extensions.dll" pdbFile="..\bin\Release\PcapDotNet.Core.Extensions.instr.pdb" instrumentInPlace="true">
<KeyFile path="PcapDotNet.snk" />
</CodeCoverageItem>
<CodeCoverageItem binaryFile="..\bin\Release\PcapDotNet.Packets.dll" pdbFile="..\bin\Release\PcapDotNet.Packets.instr.pdb" instrumentInPlace="true">
<KeyFile path="PcapDotNet.snk" />
</CodeCoverageItem>
<CodeCoverageItem binaryFile="..\bin\Release\PcapDotNet.Base.dll" pdbFile="..\bin\Release\PcapDotNet.Base.instr.pdb" instrumentInPlace="true">
<KeyFile path="PcapDotNet.snk" />
</CodeCoverageItem>
</Regular>
</CodeCoverage>
</Configuration>
</DataCollector>
</DataCollectors>
</AgentRule>
</Execution>
</TestSettings>
\ No newline at end of file
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace PcapDotNet.Base.Test
{
/// <summary>
/// Summary description for FuncExtensionsTest
/// </summary>
[TestClass]
public class FuncExtensionsTest
{
public FuncExtensionsTest()
{
//
// 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 GenerateArrayNullTest()
{
Assert.IsNotNull(FuncExtensions.GenerateArray<int>(null, 100));
Assert.Fail();
}
}
}
\ No newline at end of file
......@@ -6,12 +6,12 @@ using PcapDotNet.TestUtils;
namespace PcapDotNet.Base.Test
{
/// <summary>
/// Summary description for MoreIEnumerableTests
/// Summary description for IEnumerableExtensionsTests
/// </summary>
[TestClass]
public class MoreIEnumerableTests
public class IEnumerableExtensionsTests
{
public MoreIEnumerableTests()
public IEnumerableExtensionsTests()
{
//
// TODO: Add constructor logic here
......@@ -77,5 +77,21 @@ namespace PcapDotNet.Base.Test
Assert.IsTrue(sequence.SequenceEqual(new[] {1,2,3}.Concat(4, 5)));
}
[TestMethod]
[ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes = false)]
public void IsEmptyNullTest()
{
Assert.IsFalse(IEnumerableExtensions.IsEmpty<int>(null));
Assert.Fail();
}
[TestMethod]
[ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes = false)]
public void SequenceToStringNullTest()
{
Assert.IsNotNull(IEnumerableExtensions.SequenceToString<int>(null));
Assert.Fail();
}
}
}
\ No newline at end of file
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace PcapDotNet.Base.Test
{
/// <summary>
/// Summary description for MemberInfoExtensionsTests
/// </summary>
[TestClass]
public class MemberInfoExtensionsTests
{
public MemberInfoExtensionsTests()
{
//
// 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 GetCustomAttributesNullTest()
{
Assert.IsNotNull(MemberInfoExtensions.GetCustomAttributes<Attribute>(null, true));
Assert.Fail();
}
}
}
\ No newline at end of file
......@@ -66,8 +66,11 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="MoreIEnumerableTests.cs" />
<Compile Include="FuncExtensionsTest.cs" />
<Compile Include="IEnumerableExtensionsTests.cs" />
<Compile Include="MemberInfoExtensionsTests.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PropertyInfoExtensionsTests.cs" />
<Compile Include="UInt128Tests.cs" />
<Compile Include="UInt24Tests.cs" />
<Compile Include="UInt48Tests.cs" />
......
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace PcapDotNet.Base.Test
{
/// <summary>
/// Summary description for PropertyInfoExtensionsTests
/// </summary>
[TestClass]
public class PropertyInfoExtensionsTests
{
public PropertyInfoExtensionsTests()
{
//
// 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 GetValueNullTest()
{
Assert.IsNotNull(PropertyInfoExtensions.GetValue(null, 0));
Assert.Fail();
}
}
}
\ No newline at end of file
......@@ -56,6 +56,8 @@ namespace PcapDotNet.Base.Test
Assert.AreEqual(value, value);
Assert.AreNotEqual(value, string.Empty);
Assert.AreNotEqual(value, UInt128.MaxValue);
Assert.AreNotEqual(value, UInt128.Zero);
Assert.IsTrue(value == value);
Assert.IsFalse(value != value);
Assert.IsNotNull(value.GetHashCode());
......@@ -99,6 +101,14 @@ namespace PcapDotNet.Base.Test
}
}
[TestMethod]
[ExpectedException(typeof(ArgumentNullException), AllowDerivedTypes = false)]
public void ParseNullTest()
{
Assert.IsNotNull(UInt128.Parse(null, NumberStyles.HexNumber, CultureInfo.InvariantCulture));
Assert.Fail();
}
[TestMethod]
public void ToStringTest()
{
......
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using PcapDotNet.Core.Extensions;
using PcapDotNet.TestUtils;
namespace PcapDotNet.Core.Test
{
/// <summary>
/// Summary description for LivePacketDeviceExtensionsTests
/// </summary>
[TestClass]
public class LivePacketDeviceExtensionsTests
{
public LivePacketDeviceExtensionsTests()
{
//
// 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 GetNetworkInterfaceNullTest()
{
Assert.IsNotNull(LivePacketDeviceExtensions.GetNetworkInterface(null));
Assert.Fail();
}
}
}
\ No newline at end of file
......@@ -130,7 +130,7 @@ namespace PcapDotNet.Core.Test
TestReceivePackets(NumPacketsToSend, NumPacketsToSend / 2, int.MaxValue, 2, PacketSize, PacketCommunicatorReceiveResult.Ok, NumPacketsToSend / 2, 0, 0.02);
// Wait for more packets
TestReceivePackets(NumPacketsToSend, 0, int.MaxValue, 2, PacketSize, PacketCommunicatorReceiveResult.None, NumPacketsToSend, 2, 2.055);
TestReceivePackets(NumPacketsToSend, 0, int.MaxValue, 2, PacketSize, PacketCommunicatorReceiveResult.None, NumPacketsToSend, 2, 2.071);
TestReceivePackets(NumPacketsToSend, -1, int.MaxValue, 2, PacketSize, PacketCommunicatorReceiveResult.None, NumPacketsToSend, 2, 2.3);
TestReceivePackets(NumPacketsToSend, NumPacketsToSend + 1, int.MaxValue, 2, PacketSize, PacketCommunicatorReceiveResult.None, NumPacketsToSend, 2, 2.051);
......@@ -149,10 +149,10 @@ namespace PcapDotNet.Core.Test
TestReceivePacketsEnumerable(NumPacketsToSend, NumPacketsToSend, int.MaxValue, 2, PacketSize, NumPacketsToSend, 0, 0.3);
// Wait for less packets
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.032);
// Wait for more packets
TestReceivePacketsEnumerable(NumPacketsToSend, -1, int.MaxValue, 2, PacketSize, NumPacketsToSend, 2, 2.024);
TestReceivePacketsEnumerable(NumPacketsToSend, -1, int.MaxValue, 2, PacketSize, NumPacketsToSend, 2, 2.029);
TestReceivePacketsEnumerable(NumPacketsToSend, NumPacketsToSend + 1, int.MaxValue, 2, PacketSize, NumPacketsToSend, 2, 2.13);
// Break loop
......
......@@ -69,6 +69,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="BerkeleyPacketFilterTests.cs" />
<Compile Include="LivePacketDeviceExtensionsTests.cs" />
<Compile Include="LivePacketDeviceTests.cs" />
<Compile Include="MarshalingServicesTests.cs" />
<Compile Include="MoreIpV4Option.cs" />
......
......@@ -51,9 +51,10 @@ namespace PcapDotNet.Core.Test
[TestMethod]
public void VersionTest()
{
const string VersionNumberRegex = @"[0-9]+\.[0-9]+\.[0-9]+(?:\.[0-9]+)?";
const string VersionNumberRegex = @"[0-9]+\.[0-9]+(?:\.| beta)[0-9]+(?:\.[0-9]+)?";
const string LibpcapVersionRegex = @"(?:[0-9]+\.[0-9]+\.[0-9]+(?:\.[0-9]+)?)|(?:[0-9]\.[0-9] branch [0-9]_[0-9]_rel0b \([0-9]+\))";
// WinPcap version 4.1.1 (packet.dll version 4.1.0.1753), based on libpcap version 1.0 branch 1_0_rel0b (20091008)
// WinPcap version 4.1 beta5 (packet.dll version 4.1.0.1452), based on libpcap version 1.0.0
const string VersionRegex = "^WinPcap version " + VersionNumberRegex + @" \(packet\.dll version " + VersionNumberRegex + @"\), based on libpcap version " + LibpcapVersionRegex + "$";
string version = PcapLibrary.Version;
MoreAssert.IsMatch(VersionRegex, version);
......
......@@ -132,6 +132,9 @@ namespace PcapDotNet.Packets.Test
Assert.AreNotEqual(2, packet.Ethernet.IpV4.Fragmentation, "IP Fragmentation");
Assert.IsTrue(ipV4Layer.Fragmentation == packet.Ethernet.IpV4.Fragmentation, "IP Fragmentation");
Assert.IsFalse(ipV4Layer.Fragmentation != packet.Ethernet.IpV4.Fragmentation, "IP Fragmentation");
Assert.IsFalse(ipV4Layer.Fragmentation.Equals(0), "IP Fragmentation");
if (ipV4Layer.Fragmentation.Offset != 0)
Assert.AreNotEqual(ipV4Layer.Fragmentation, IpV4Fragmentation.None, "IP Fragmentation");
Assert.AreEqual(ipV4Layer.Fragmentation.GetHashCode(), packet.Ethernet.IpV4.Fragmentation.GetHashCode(), "IP Fragmentation");
Assert.AreEqual(ipV4Layer.Fragmentation.Options, packet.Ethernet.IpV4.Fragmentation.Options, "IP Fragmentation");
Assert.AreEqual(ipV4Layer.Fragmentation.Offset, packet.Ethernet.IpV4.Fragmentation.Offset, "IP Fragmentation");
......@@ -337,6 +340,7 @@ namespace PcapDotNet.Packets.Test
Assert.AreEqual(timedAddress1, timedAddress2);
Assert.IsTrue(timedAddress1 == timedAddress2);
Assert.IsFalse(timedAddress1 != timedAddress2);
Assert.IsFalse(timedAddress1.Equals(0));
}
[TestMethod]
......
......@@ -238,9 +238,6 @@ namespace PcapDotNet.Packets.IpV4
/// <returns>On success - the complex option read. On failure - null.</returns>
Option IOptionComplexFactory.CreateInstance(byte[] buffer, ref int offset, byte valueLength)
{
// if (buffer == null)
// throw new ArgumentNullException("buffer");
if (valueLength != OptionValueLength)
return null;
......
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