Commit fb4532d0 authored by Brickner_cp's avatar Brickner_cp

--no commit message

--no commit message
parent 6d0cb5d9
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace PcapDotNet.Core.Test
{
/// <summary>
/// Summary description for BerkeleyPacketFilterTests
/// </summary>
[TestClass]
public class BerkeleyPacketFilterTests
{
public BerkeleyPacketFilterTests()
{
//
// TODO: Add constructor logic here
//
}
private TestContext testContextInstance;
/// <summary>
///Gets or sets the test context which provides
///information about and functionality for the current test run.
///</summary>
public TestContext TestContext
{
get
{
return testContextInstance;
}
set
{
testContextInstance = value;
}
}
#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(InvalidOperationException))]
public void BadFilterErrorTest()
{
using (PacketCommunicator communicator = LivePacketDeviceTests.OpenLiveDevice())
{
communicator.SetFilter("illegal filter string");
}
}
}
}
\ No newline at end of file
......@@ -159,6 +159,8 @@ namespace PcapDotNet.Core.Test
Assert.AreEqual(PacketCommunicatorMode.Capture, communicator.Mode);
Assert.IsFalse(communicator.NonBlocking);
Assert.AreEqual(PacketDevice.DefaultSnapshotLength, communicator.SnapshotLength);
Assert.AreEqual(2, communicator.FileMajorVersion);
Assert.AreEqual(4, communicator.FileMinorVersion);
return communicator;
}
catch (Exception)
......
......@@ -42,6 +42,7 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="BerkeleyPacketFilterTests.cs" />
<Compile Include="MoreAssert.cs" />
<Compile Include="LivePacketDeviceTests.cs" />
<Compile Include="MoreRandom.cs" />
......
......@@ -8,12 +8,13 @@ namespace PcapDotNet { namespace Core
public ref class BerkeleyPacketFilter : System::IDisposable
{
public:
BerkeleyPacketFilter(pcap_t* pcapDescriptor, System::String^ filterString, IpV4SocketAddress^ netmask);
void SetFilter(pcap_t* pcapDescriptor);
~BerkeleyPacketFilter(); // IDisposable
internal:
BerkeleyPacketFilter(pcap_t* pcapDescriptor, System::String^ filterString, IpV4SocketAddress^ netmask);
private:
bpf_program* _bpf;
};
......
......@@ -308,11 +308,6 @@ void PacketCommunicator::AssertMode(PacketCommunicatorMode mode)
throw gcnew InvalidOperationException("Wrong Mode. Must be in mode " + mode.ToString() + " and not in mode " + Mode.ToString());
}
String^ PacketCommunicator::ErrorMessage::get()
{
return PcapError::GetErrorMessage(_pcapDescriptor);
}
InvalidOperationException^ PacketCommunicator::BuildInvalidOperation(System::String^ errorMessage)
{
return PcapError::BuildInvalidOperation(errorMessage, _pcapDescriptor);
......
......@@ -119,11 +119,6 @@ namespace PcapDotNet { namespace Core
void AssertMode(PacketCommunicatorMode mode);
property System::String^ ErrorMessage
{
System::String^ get();
}
ref class PacketHandler
{
public:
......
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