diff --git a/AGENTS.md b/AGENTS.md
index 0d9d1d8..2e2568e 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -2,7 +2,7 @@
## Overview
-This repository contains a .NET 10 solution for working with Linux iptables from C#. The managed code lives under `IPTables.Net/`, the NUnit tests live under `IPTables.Net.Tests/`, and the native helper library used by the libiptc-based adapter lives under `ipthelper/`.
+This repository contains a .NET 10 solution for working with Linux iptables from C#. The managed code lives under `IPTables.Net/`, the xUnit tests live under `IPTables.Net.Tests/`, and the native helper library used by the libiptc-based adapter lives under `ipthelper/`.
## Build And Test
@@ -31,7 +31,7 @@ Both scripts will bootstrap a usable .NET SDK if `dotnet` is missing. By default
## Development Guidance
-- Keep changes narrow and add or update NUnit coverage in `IPTables.Net.Tests/` when behavior changes.
+- Keep changes narrow and add or update xUnit coverage in `IPTables.Net.Tests/` when behavior changes.
- Prefer following the existing project layout instead of introducing new abstractions unless the current design is clearly blocking the work.
- When changing native interop behavior, verify both the managed call sites in `IPTables.Net/Iptables/NativeLibrary/` and the corresponding code in `ipthelper/`.
- The tests project is also the best source of usage examples for the public API.
diff --git a/IPTables.Net.TestFramework/IPTables.Net.TestFramework.csproj b/IPTables.Net.TestFramework/IPTables.Net.TestFramework.csproj
index 8355db5..06838cc 100644
--- a/IPTables.Net.TestFramework/IPTables.Net.TestFramework.csproj
+++ b/IPTables.Net.TestFramework/IPTables.Net.TestFramework.csproj
@@ -3,11 +3,16 @@
net10.0
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/IPTables.Net.TestFramework/MockIpsetSystemFactory.cs b/IPTables.Net.TestFramework/MockIpsetSystemFactory.cs
index c2b6aa1..7ef6a81 100644
--- a/IPTables.Net.TestFramework/MockIpsetSystemFactory.cs
+++ b/IPTables.Net.TestFramework/MockIpsetSystemFactory.cs
@@ -4,7 +4,6 @@
using System.Linq;
using SystemInteract;
using IPTables.Net.IpSet;
-using NUnit.Framework;
namespace IPTables.Net.TestFramework
{
@@ -31,7 +30,7 @@ public void TestSync(IpSetSets rulesNew, List expectedCommands)
{
TestSync(rulesNew);
- CollectionAssert.AreEqual(expectedCommands, Commands.Select(a => a.Value).ToList());
+ Assert.Equal(expectedCommands, Commands.Select(a => a.Value).ToList());
}
}
}
diff --git a/IPTables.Net.TestFramework/MockIptablesSystemFactory.cs b/IPTables.Net.TestFramework/MockIptablesSystemFactory.cs
index 2cab3b9..eb45f24 100644
--- a/IPTables.Net.TestFramework/MockIptablesSystemFactory.cs
+++ b/IPTables.Net.TestFramework/MockIptablesSystemFactory.cs
@@ -6,7 +6,6 @@
using IPTables.Net.Iptables;
using IPTables.Net.Iptables.Adapter.Client;
using IPTables.Net.Iptables.TableSync;
-using NUnit.Framework;
namespace IPTables.Net.TestFramework
{
@@ -57,7 +56,7 @@ public void TestSync(IIPTablesAdapterClient client, IpTablesRuleSet rules
if (expectedCommands != null)
{
- CollectionAssert.AreEqual(expectedCommands, ExecutionLog.Select(a => a.Value).ToList());
+ Assert.Equal(expectedCommands, ExecutionLog.Select(a => a.Value).ToList());
}
}
}
diff --git a/IPTables.Net.Tests/CheckDebugComparison.cs b/IPTables.Net.Tests/CheckDebugComparison.cs
index 253b1a8..c3387f2 100644
--- a/IPTables.Net.Tests/CheckDebugComparison.cs
+++ b/IPTables.Net.Tests/CheckDebugComparison.cs
@@ -1,5 +1,4 @@
using IPTables.Net.Iptables.Modules.HashLimit;
-using NUnit.Framework;
using System;
using System.Linq;
using IPTables.Net.Iptables;
@@ -7,10 +6,9 @@
namespace IPTables.Net.Tests
{
- [TestFixture]
public class CheckDebugComparison
{
- [TestCase]
+ [Fact]
public void TestHashLimitMemberProperties()
{
var hl = new HashLimitModule(4);
diff --git a/IPTables.Net.Tests/CheckInternalTables.cs b/IPTables.Net.Tests/CheckInternalTables.cs
index 7b9157f..cfc4c03 100644
--- a/IPTables.Net.Tests/CheckInternalTables.cs
+++ b/IPTables.Net.Tests/CheckInternalTables.cs
@@ -3,14 +3,12 @@
using System.Linq;
using System.Text;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- class CheckInternalTables
+ public class CheckInternalTables
{
- [Test]
+ [Fact]
public void TestChains()
{
TestChain("filter", "INPUT");
@@ -33,7 +31,7 @@ public void TestChains()
private void TestChain(string table, string chain)
{
- Assert.IsTrue(IPTablesTables.IsInternalChain(table, chain), String.Format("{0}:{1} should be internal", table, chain));
+ Assert.True(IPTablesTables.IsInternalChain(table, chain), String.Format("{0}:{1} should be internal", table, chain));
}
}
}
diff --git a/IPTables.Net.Tests/ConntrackLibraryTests.cs b/IPTables.Net.Tests/ConntrackLibraryTests.cs
index c74c996..8ad5418 100644
--- a/IPTables.Net.Tests/ConntrackLibraryTests.cs
+++ b/IPTables.Net.Tests/ConntrackLibraryTests.cs
@@ -8,64 +8,44 @@
using IPTables.Net.Conntrack;
using IPTables.Net.Iptables.NativeLibrary;
using IPTables.Net.Supporting;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- [Category("NotWorkingOnTravis")]
- class ConntrackLibraryTests
+ [Trait("Category", "NotWorkingOnTravis")]
+ public class ConntrackLibraryTests
{
- public static bool IsLinux
- {
- get
- {
- int p = (int)Environment.OSVersion.Platform;
- return (p == 4) || (p == 6) || (p == 128);
- }
- }
-
- [Test]
+ [Fact]
public void TestStructureSize()
{
- Assert.AreEqual(8 + IntPtr.Size, Marshal.SizeOf(typeof(ConntrackQueryFilter)));
+ Assert.Equal(8 + IntPtr.Size, Marshal.SizeOf(typeof(ConntrackQueryFilter)));
}
- [Test]
+ [Fact]
public void TestDump()
{
- if (IsLinux)
- {
- if (Environment.GetEnvironmentVariable("SKIP_SYSTEM_TESTS") == "1")
- {
- Assert.Ignore();
- }
- ConntrackSystem cts = new ConntrackSystem();
- List list = new List();
- cts.Dump(false,list.Add);
- }
+ TestEnvironment.RequireLinuxSystemTests();
+
+ ConntrackSystem cts = new ConntrackSystem();
+ List list = new List();
+ cts.Dump(false, list.Add);
}
- [Test]
+ [Fact]
public void TestDumpFiltered()
{
- if (IsLinux)
- {
- if (Environment.GetEnvironmentVariable("SKIP_SYSTEM_TESTS") == "1")
- {
- Assert.Ignore();
- }
- ConntrackSystem cts = new ConntrackSystem();
- IPAddress addr = IPAddress.Parse("1.1.1.1");
- UInt32 addr32;
- unchecked
- {
- addr32 = (UInt32)addr.ToInt();
- }
-
+ TestEnvironment.RequireLinuxSystemTests();
+ ConntrackSystem cts = new ConntrackSystem();
+ IPAddress addr = IPAddress.Parse("1.1.1.1");
+ UInt32 addr32;
+ unchecked
+ {
+ addr32 = (UInt32)addr.ToInt();
+ }
- var pinned = GCHandle.Alloc(addr32, GCHandleType.Pinned);
+ var pinned = GCHandle.Alloc(addr32, GCHandleType.Pinned);
+ try
+ {
ConntrackQueryFilter[] qf = new ConntrackQueryFilter[]
{
new ConntrackQueryFilter{Key = cts.GetConstant("CTA_TUPLE_ORIG"), Max = cts.GetConstant("CTA_TUPLE_MAX"), CompareLength = 0},
@@ -77,7 +57,9 @@ public void TestDumpFiltered()
List list = new List();
cts.Dump(false, list.Add, qf);
-
+ }
+ finally
+ {
pinned.Free();
}
}
diff --git a/IPTables.Net.Tests/EscapeHelperTests.cs b/IPTables.Net.Tests/EscapeHelperTests.cs
index 1e9733f..8eadcb9 100644
--- a/IPTables.Net.Tests/EscapeHelperTests.cs
+++ b/IPTables.Net.Tests/EscapeHelperTests.cs
@@ -4,35 +4,33 @@
using System.Text;
using IPTables.Net.Iptables.Helpers;
using IPTables.Net.Supporting;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- class EscapeHelperTests
+ public class EscapeHelperTests
{
- [Test]
+ [Fact]
public void TestSpaces()
{
- Assert.AreEqual("'a word'", ShellHelper.EscapeArguments("a word"));
- Assert.AreEqual("singleword", ShellHelper.EscapeArguments("singleword"));
+ Assert.Equal("'a word'", ShellHelper.EscapeArguments("a word"));
+ Assert.Equal("singleword", ShellHelper.EscapeArguments("singleword"));
}
- [Test]
+ [Fact]
public void TestPipe()
{
- Assert.AreEqual("'|'", ShellHelper.EscapeArguments("|"));
- Assert.AreEqual("'a|word'", ShellHelper.EscapeArguments("a|word"));
- Assert.AreEqual("singleword", ShellHelper.EscapeArguments("singleword"));
+ Assert.Equal("'|'", ShellHelper.EscapeArguments("|"));
+ Assert.Equal("'a|word'", ShellHelper.EscapeArguments("a|word"));
+ Assert.Equal("singleword", ShellHelper.EscapeArguments("singleword"));
}
- [Test]
+ [Fact]
public void TestSpace()
{
- Assert.AreEqual("a word", ShellHelper.BuildArgumentString(new []{"a", "word"}));
- Assert.AreEqual("\"two words\"", ShellHelper.BuildArgumentString(new[] { "two words" }));
- Assert.AreEqual("\"two words and \\\"punctuation\\\"\"", ShellHelper.BuildArgumentString(new[] { "two words and \"punctuation\"" }));
- Assert.AreEqual("bash -c \"bash -c \\\"echo a\\\"\"", ShellHelper.BuildArgumentString(new[] { "bash", "-c", ShellHelper.BuildArgumentString(new []{"bash", "-c", "echo a"}) }));
- Assert.AreEqual("bash -c \"bash -c \\\"echo \\\\\\\"a\\\\\\\"\\\"\"", ShellHelper.BuildArgumentString(new[] { "bash", "-c", ShellHelper.BuildArgumentString(new[] { "bash", "-c", "echo \"a\"" }) }));
+ Assert.Equal("a word", ShellHelper.BuildArgumentString(new []{"a", "word"}));
+ Assert.Equal("\"two words\"", ShellHelper.BuildArgumentString(new[] { "two words" }));
+ Assert.Equal("\"two words and \\\"punctuation\\\"\"", ShellHelper.BuildArgumentString(new[] { "two words and \"punctuation\"" }));
+ Assert.Equal("bash -c \"bash -c \\\"echo a\\\"\"", ShellHelper.BuildArgumentString(new[] { "bash", "-c", ShellHelper.BuildArgumentString(new []{"bash", "-c", "echo a"}) }));
+ Assert.Equal("bash -c \"bash -c \\\"echo \\\\\\\"a\\\\\\\"\\\"\"", ShellHelper.BuildArgumentString(new[] { "bash", "-c", ShellHelper.BuildArgumentString(new[] { "bash", "-c", "echo \"a\"" }) }));
}
}
}
diff --git a/IPTables.Net.Tests/GraphLayoutTests.cs b/IPTables.Net.Tests/GraphLayoutTests.cs
index 34dd025..e6f27ef 100644
--- a/IPTables.Net.Tests/GraphLayoutTests.cs
+++ b/IPTables.Net.Tests/GraphLayoutTests.cs
@@ -10,14 +10,12 @@
using IPTables.Net.Iptables.Modules;
using IPTables.Net.Iptables.Modules.Comment;
using IPTables.Net.Tests.MockSystem;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- class GraphLayoutTests
+ public class GraphLayoutTests
{
- [Test]
+ [Fact]
public void TestAddSingles()
{
List addresses = new List();
@@ -29,9 +27,9 @@ public void TestAddSingles()
CidrGraph graph = CidrGraph.BuildGraph(addresses);
//These numbers are based on the best I could do on paper. This less than perfect algorithm can beat that.
- Assert.IsTrue(graph.CalculateMaxPathLength() < 20, "Criteria for a good algorithm (max): " + graph.CalculateMaxPathLength());
- Assert.IsTrue(graph.CalculateMinPathLength() < 10, "Criteria for a good algorithm (min): " + graph.CalculateMinPathLength());
- Assert.IsTrue(graph.CalculateAveragePathLength() < 11, "Criteria for a good algorithm (avg): " + graph.CalculateAveragePathLength());
+ Assert.True(graph.CalculateMaxPathLength() < 20, "Criteria for a good algorithm (max): " + graph.CalculateMaxPathLength());
+ Assert.True(graph.CalculateMinPathLength() < 10, "Criteria for a good algorithm (min): " + graph.CalculateMinPathLength());
+ Assert.True(graph.CalculateAveragePathLength() < 11, "Criteria for a good algorithm (avg): " + graph.CalculateAveragePathLength());
}
diff --git a/IPTables.Net.Tests/IPTables.Net.Tests.csproj b/IPTables.Net.Tests/IPTables.Net.Tests.csproj
index 709fe58..91f94ce 100644
--- a/IPTables.Net.Tests/IPTables.Net.Tests.csproj
+++ b/IPTables.Net.Tests/IPTables.Net.Tests.csproj
@@ -1,6 +1,7 @@
+ Exe
net10.0
@@ -8,11 +9,18 @@
+
+
+
+
-
-
+
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+ all
+
+
diff --git a/IPTables.Net.Tests/IPTablesRuleTests.cs b/IPTables.Net.Tests/IPTablesRuleTests.cs
index 9991582..5df8828 100644
--- a/IPTables.Net.Tests/IPTablesRuleTests.cs
+++ b/IPTables.Net.Tests/IPTablesRuleTests.cs
@@ -2,22 +2,20 @@
using System.Security.Cryptography;
using IPTables.Net.Iptables;
using IPTables.Net.Iptables.Modules.Mark;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class IPTablesRuleTests
+ public class IPTablesRuleTests
{
- [Test]
+ [Fact]
public void TestDefaultChain()
{
IpTablesChainSet chains = new IpTablesChainSet(4);
var rule = IpTablesRule.Parse("-A PREROUTING -s 1.1.1.1 -j TEST", null, chains, 4, "raw", IpTablesRule.ChainCreateMode.CreateNewChainIfNeeded);
- Assert.AreEqual("raw", rule.Chain.Table);
+ Assert.Equal("raw", rule.Chain.Table);
}
- [Test]
+ [Fact]
public void TestAppendRule()
{
IpTablesChainSet chains = new IpTablesChainSet(4);
@@ -25,7 +23,7 @@ public void TestAppendRule()
rule.AppendToRule("! -m devgroup --src-group 0x2");
}
- [Test]
+ [Fact]
public void TestGetModuleOrLoad_CanLoadBareTargetAfterParse()
{
IpTablesChainSet chains = new IpTablesChainSet(4);
@@ -35,7 +33,7 @@ public void TestGetModuleOrLoad_CanLoadBareTargetAfterParse()
Assert.NotNull(mark);
mark.SetOrMark(1);
- Assert.AreEqual("-A INPUT -j MARK --set-xmark 0x1/0x1", rule.GetActionCommand());
+ Assert.Equal("-A INPUT -j MARK --set-xmark 0x1/0x1", rule.GetActionCommand());
}
}
}
diff --git a/IPTables.Net.Tests/IpSetCidrTests.cs b/IPTables.Net.Tests/IpSetCidrTests.cs
index bded181..ace8a62 100644
--- a/IPTables.Net.Tests/IpSetCidrTests.cs
+++ b/IPTables.Net.Tests/IpSetCidrTests.cs
@@ -5,14 +5,12 @@
using System.Text;
using IPTables.Net.IpSet;
using IPTables.Net.TestFramework;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- class IpSetCidrTests
+ public class IpSetCidrTests
{
- [Test]
+ [Fact]
public void TestSyncCreateLarger()
{
var systemFactory = new MockIpsetSystemFactory();
@@ -40,7 +38,7 @@ public void TestSyncCreateLarger()
});
}
- [Test]
+ [Fact]
public void TestSyncLargerIsTheSame()
{
var systemFactory = new MockIpsetSystemFactory();
@@ -66,7 +64,7 @@ public void TestSyncLargerIsTheSame()
{
});
}
- [Test]
+ [Fact]
public void TestSyncCreateSmaller()
{
var systemFactory = new MockIpsetSystemFactory();
@@ -94,7 +92,7 @@ public void TestSyncCreateSmaller()
});
}
- [Test]
+ [Fact]
public void TestSyncCreateMultipleLarger()
{
var systemFactory = new MockIpsetSystemFactory();
@@ -123,7 +121,7 @@ public void TestSyncCreateMultipleLarger()
"add test 8.8.0.0/16"
});
}
- [Test]
+ [Fact]
public void TestSyncCreateSmallerWithPort()
{
var systemFactory = new MockIpsetSystemFactory();
@@ -152,7 +150,7 @@ public void TestSyncCreateSmallerWithPort()
"add test 8.8.8.0/30,udp:123"
});
}
- [Test]
+ [Fact]
public void TestSyncNoChangeWithPort()
{
var systemFactory = new MockIpsetSystemFactory();
diff --git a/IPTables.Net.Tests/IpSetParseTest.cs b/IPTables.Net.Tests/IpSetParseTest.cs
index e4b71fe..cf5ad8b 100644
--- a/IPTables.Net.Tests/IpSetParseTest.cs
+++ b/IPTables.Net.Tests/IpSetParseTest.cs
@@ -5,60 +5,58 @@
using System.Text;
using IPTables.Net.IpSet;
using IPTables.Net.Iptables.DataTypes;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- class IpSetParseTest
+ public class IpSetParseTest
{
- [Test]
+ [Fact]
public void TestParseSet1()
{
String toParse = "test_set hash:ip family inet hashsize 10 maxelem 14";
var set = IpSetSet.Parse(toParse, null);
- Assert.AreEqual("test_set", set.Name);
- Assert.AreEqual(IpSetType.Hash | IpSetType.Ip, set.Type);
- Assert.AreEqual(10, set.HashSize);
- Assert.AreEqual(14, set.MaxElem);
+ Assert.Equal("test_set", set.Name);
+ Assert.Equal(IpSetType.Hash | IpSetType.Ip, set.Type);
+ Assert.Equal(10, set.HashSize);
+ Assert.Equal((uint)14, set.MaxElem);
- Assert.AreEqual(toParse,set.GetCommand());
+ Assert.Equal(toParse,set.GetCommand());
}
- [Test]
+ [Fact]
public void TestParseSet2()
{
String toParse = "test_set hash:ip family inet hashsize 10 maxelem 14 timeout 613";
var set = IpSetSet.Parse(toParse, null);
- Assert.AreEqual("test_set", set.Name);
- Assert.AreEqual(IpSetType.Hash | IpSetType.Ip, set.Type);
- Assert.AreEqual(10, set.HashSize);
- Assert.AreEqual(14, set.MaxElem);
- Assert.AreEqual(613, set.Timeout);
+ Assert.Equal("test_set", set.Name);
+ Assert.Equal(IpSetType.Hash | IpSetType.Ip, set.Type);
+ Assert.Equal(10, set.HashSize);
+ Assert.Equal((uint)14, set.MaxElem);
+ Assert.Equal(613, set.Timeout);
- Assert.AreEqual(toParse, set.GetCommand());
+ Assert.Equal(toParse, set.GetCommand());
}
- [Test]
+ [Fact]
public void TestParseSet3()
{
String toParse = "test_set bitmap:port range 123-234 timeout 613";
var set = IpSetSet.Parse(toParse, null);
- Assert.AreEqual("test_set", set.Name);
- Assert.AreEqual(IpSetType.Bitmap | IpSetType.Port, set.Type);
- Assert.AreEqual(new PortOrRange(123,234,'-'), set.BitmapRange);
- Assert.AreEqual(613, set.Timeout);
+ Assert.Equal("test_set", set.Name);
+ Assert.Equal(IpSetType.Bitmap | IpSetType.Port, set.Type);
+ Assert.Equal(new PortOrRange(123,234,'-'), set.BitmapRange);
+ Assert.Equal(613, set.Timeout);
- Assert.AreEqual(toParse, set.GetCommand());
+ Assert.Equal(toParse, set.GetCommand());
}
- [Test]
+ [Fact]
public void TestParseEntry1()
{
@@ -71,11 +69,11 @@ public void TestParseEntry1()
String toParse = "test_set 8.8.8.8";
var entry = IpSetEntry.Parse(toParse, sets);
- Assert.AreEqual("test_set", entry.Set.Name);
- Assert.AreEqual(IPAddress.Parse("8.8.8.8"), entry.Cidr.Address);
+ Assert.Equal("test_set", entry.Set.Name);
+ Assert.Equal(IPAddress.Parse("8.8.8.8"), entry.Cidr.Address);
}
- [Test]
+ [Fact]
public void TestParseEntry2()
{
@@ -88,12 +86,12 @@ public void TestParseEntry2()
String toParse = "test_set 8.8.8.8,tcp:80";
var entry = IpSetEntry.Parse(toParse, sets);
- Assert.AreEqual("test_set", entry.Set.Name);
- Assert.AreEqual(IPAddress.Parse("8.8.8.8"), entry.Cidr.Address);
- Assert.AreEqual(80, entry.Port);
+ Assert.Equal("test_set", entry.Set.Name);
+ Assert.Equal(IPAddress.Parse("8.8.8.8"), entry.Cidr.Address);
+ Assert.Equal(80, entry.Port);
}
- [Test]
+ [Fact]
public void TestParseEntryIp()
{
@@ -106,12 +104,12 @@ public void TestParseEntryIp()
String toParse = "test_set 1.2.3.4";
var entry = IpSetEntry.Parse(toParse, sets);
- Assert.AreEqual("test_set", entry.Set.Name);
- Assert.AreEqual(IPAddress.Parse("1.2.3.4"), entry.Cidr.Address);
+ Assert.Equal("test_set", entry.Set.Name);
+ Assert.Equal(IPAddress.Parse("1.2.3.4"), entry.Cidr.Address);
}
- [Test]
+ [Fact]
public void TestParseEntryIpPort()
{
@@ -124,13 +122,13 @@ public void TestParseEntryIpPort()
String toParse = "test_set 1.1.1.1,tcp:80";
var entry = IpSetEntry.Parse(toParse, sets);
- Assert.AreEqual("test_set", entry.Set.Name);
- Assert.AreEqual(IPAddress.Parse("1.1.1.1"), entry.Cidr.Address);
- Assert.AreEqual(80, entry.Port);
- Assert.AreEqual("tcp", entry.Protocol);
+ Assert.Equal("test_set", entry.Set.Name);
+ Assert.Equal(IPAddress.Parse("1.1.1.1"), entry.Cidr.Address);
+ Assert.Equal(80, entry.Port);
+ Assert.Equal("tcp", entry.Protocol);
}
- [Test]
+ [Fact]
public void TestParseEntryIpIpFlag()
{
@@ -143,12 +141,12 @@ public void TestParseEntryIpIpFlag()
String toParse = "test_set 1.1.1.1,2.2.2.2,80";
var entry = IpSetEntry.Parse(toParse, sets);
- Assert.AreEqual("test_set", entry.Set.Name);
- Assert.AreEqual(IPAddress.Parse("1.1.1.1"), entry.Cidr.Address);
- Assert.AreEqual(80, entry.Port);;
+ Assert.Equal("test_set", entry.Set.Name);
+ Assert.Equal(IPAddress.Parse("1.1.1.1"), entry.Cidr.Address);
+ Assert.Equal(80, entry.Port);;
}
- [Test]
+ [Fact]
public void TestParseEntryCtIpPort()
{
@@ -161,14 +159,14 @@ public void TestParseEntryCtIpPort()
String toParse = "test_set 1.1.1.1,tcp:80";
var entry = IpSetEntry.Parse(toParse, sets);
- Assert.AreEqual("test_set", entry.Set.Name);
- Assert.AreEqual(IPAddress.Parse("1.1.1.1"), entry.Cidr.Address);
- Assert.AreEqual(80, entry.Port);
- Assert.AreEqual("tcp", entry.Protocol);
+ Assert.Equal("test_set", entry.Set.Name);
+ Assert.Equal(IPAddress.Parse("1.1.1.1"), entry.Cidr.Address);
+ Assert.Equal(80, entry.Port);
+ Assert.Equal("tcp", entry.Protocol);
}
- [Test]
+ [Fact]
public void TestParseEntryIpIp()
{
@@ -181,11 +179,11 @@ public void TestParseEntryIpIp()
String toParse = "test_set 1.2.3.4,2.2.2.2";
var entry = IpSetEntry.Parse(toParse, sets);
- Assert.AreEqual("test_set", entry.Set.Name);
- Assert.AreEqual(IPAddress.Parse("1.2.3.4"), entry.Cidr.Address);
- Assert.AreEqual(IPAddress.Parse("2.2.2.2"), entry.Cidr2.Address);
+ Assert.Equal("test_set", entry.Set.Name);
+ Assert.Equal(IPAddress.Parse("1.2.3.4"), entry.Cidr.Address);
+ Assert.Equal(IPAddress.Parse("2.2.2.2"), entry.Cidr2.Address);
}
- [Test]
+ [Fact]
public void TestParseEntryIpCounters()
{
@@ -198,10 +196,10 @@ public void TestParseEntryIpCounters()
String toParse = "test_set 1.2.3.4 packets 1 bytes 40";
var entry = IpSetEntry.Parse(toParse, sets);
- Assert.AreEqual("test_set", entry.Set.Name);
- Assert.AreEqual(IPAddress.Parse("1.2.3.4"), entry.Cidr.Address);
+ Assert.Equal("test_set", entry.Set.Name);
+ Assert.Equal(IPAddress.Parse("1.2.3.4"), entry.Cidr.Address);
}
- [Test]
+ [Fact]
public void TestParseEntryIpIpCounters()
{
var set = IpSetSet.Parse("test_set hash:ip,ip family inet hashsize 10 maxelem 14", null);
@@ -213,9 +211,9 @@ public void TestParseEntryIpIpCounters()
String toParse = "test_set 1.2.3.4,2.2.2.2 packets 1 bytes 40";
var entry = IpSetEntry.Parse(toParse, sets);
- Assert.AreEqual("test_set", entry.Set.Name);
- Assert.AreEqual(IPAddress.Parse("1.2.3.4"), entry.Cidr.Address);
- Assert.AreEqual(IPAddress.Parse("2.2.2.2"), entry.Cidr2.Address);
+ Assert.Equal("test_set", entry.Set.Name);
+ Assert.Equal(IPAddress.Parse("1.2.3.4"), entry.Cidr.Address);
+ Assert.Equal(IPAddress.Parse("2.2.2.2"), entry.Cidr2.Address);
}
}
}
diff --git a/IPTables.Net.Tests/IpSetSyncTests.cs b/IPTables.Net.Tests/IpSetSyncTests.cs
index 524acd3..1e7df3f 100644
--- a/IPTables.Net.Tests/IpSetSyncTests.cs
+++ b/IPTables.Net.Tests/IpSetSyncTests.cs
@@ -5,15 +5,13 @@
using System.Text;
using IPTables.Net.IpSet;
using IPTables.Net.TestFramework;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- class IpSetSyncTests
+ public class IpSetSyncTests
{
- [Test]
+ [Fact]
public void TestSyncIPPort1()
{
var systemFactory = new MockIpsetSystemFactory();
@@ -44,7 +42,7 @@ public void TestSyncIPPort1()
}
- [Test]
+ [Fact]
public void TestSyncCreate()
{
var systemFactory = new MockIpsetSystemFactory();
@@ -70,7 +68,7 @@ public void TestSyncCreate()
});
}
- [Test]
+ [Fact]
public void TestSyncDelete()
{
var systemFactory = new MockIpsetSystemFactory();
@@ -95,7 +93,7 @@ public void TestSyncDelete()
});
}
- [Test]
+ [Fact]
public void TestSyncEntryAdd()
{
var systemFactory = new MockIpsetSystemFactory();
@@ -120,7 +118,7 @@ public void TestSyncEntryAdd()
"add test 8.8.8.8"
});
}
- [Test]
+ [Fact]
public void TestSyncEntrySameIp()
{
var systemFactory = new MockIpsetSystemFactory();
@@ -145,7 +143,7 @@ public void TestSyncEntrySameIp()
{
});
}
- [Test]
+ [Fact]
public void TestSyncEntryMultipleIp()
{
var systemFactory = new MockIpsetSystemFactory();
@@ -174,7 +172,7 @@ public void TestSyncEntryMultipleIp()
{
});
}
- [Test]
+ [Fact]
public void TestSyncEntryOrderIp()
{
var systemFactory = new MockIpsetSystemFactory();
@@ -204,7 +202,7 @@ public void TestSyncEntryOrderIp()
});
}
- [Test]
+ [Fact]
public void TestSyncEntryDelete()
{
var systemFactory = new MockIpsetSystemFactory();
@@ -230,7 +228,7 @@ public void TestSyncEntryDelete()
});
}
- [Test]
+ [Fact]
public void TestSyncEntryNotValues()
{
var systemFactory = new MockIpsetSystemFactory();
@@ -258,7 +256,7 @@ public void TestSyncEntryNotValues()
});
}
- [Test]
+ [Fact]
public void TestBitmapPort()
{
var systemFactory = new MockIpsetSystemFactory();
@@ -286,7 +284,7 @@ public void TestBitmapPort()
});
}
- [Test]
+ [Fact]
public void TestBitmapPortNoChange()
{
var systemFactory = new MockIpsetSystemFactory();
@@ -319,7 +317,7 @@ public void TestBitmapPortNoChange()
});
}
- [Test]
+ [Fact]
public void TestSyncCreateNet()
{
var systemFactory = new MockIpsetSystemFactory();
@@ -345,7 +343,7 @@ public void TestSyncCreateNet()
});
}
- [Test]
+ [Fact]
public void TestSyncChangeNet()
{
var systemFactory = new MockIpsetSystemFactory();
@@ -375,7 +373,7 @@ public void TestSyncChangeNet()
});
}
- [Test]
+ [Fact]
public void TestSameNet()
{
var systemFactory = new MockIpsetSystemFactory();
diff --git a/IPTables.Net.Tests/IpTableSystemTests.cs b/IPTables.Net.Tests/IpTableSystemTests.cs
index 69eb93f..a17d316 100644
--- a/IPTables.Net.Tests/IpTableSystemTests.cs
+++ b/IPTables.Net.Tests/IpTableSystemTests.cs
@@ -1,56 +1,23 @@
using IPTables.Net.Exceptions;
using IPTables.Net.Iptables;
using IPTables.Net.Iptables.Adapter;
-using NUnit.Framework;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
using SystemInteract.Local;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class IpTableSystemTests
+ public class IpTableSystemTests
{
- [SetUp]
- public void Initialize()
- {
- if (IsLinux)
- {
- if (Environment.GetEnvironmentVariable("SKIP_SYSTEM_TESTS") != "1")
- {
- _system = new IpTablesSystem(system: new LocalFactory(), tableAdapter: new IPTablesBinaryAdapter());
- }
- }
- }
+ private const int IP_VERSION = 4;
- [Test]
+ [Fact]
public void TestGetRules()
{
- if (IsLinux)
- {
- if (Environment.GetEnvironmentVariable("SKIP_SYSTEM_TESTS") == "1")
- {
- Assert.Ignore();
- }
+ TestEnvironment.RequireLinuxSystemTests();
- // Invalid table cause exception
- Assert.Throws(() => _system.GetRules("_invalidTableName", IP_VERSION));
- }
- }
+ var system = new IpTablesSystem(system: new LocalFactory(), tableAdapter: new IPTablesBinaryAdapter());
- public static bool IsLinux
- {
- get
- {
- int p = (int)Environment.OSVersion.Platform;
- return (p == 4) || (p == 6) || (p == 128);
- }
+ // Invalid table cause exception
+ Assert.Throws(() => system.GetRules("_invalidTableName", IP_VERSION));
}
-
- private IpTablesSystem _system;
- private const int IP_VERSION = 4;
}
}
diff --git a/IPTables.Net.Tests/IpTablesBinarySyncChainTests.cs b/IPTables.Net.Tests/IpTablesBinarySyncChainTests.cs
index 629a7a0..48e0382 100644
--- a/IPTables.Net.Tests/IpTablesBinarySyncChainTests.cs
+++ b/IPTables.Net.Tests/IpTablesBinarySyncChainTests.cs
@@ -8,14 +8,12 @@
using IPTables.Net.Iptables.Modules.Comment;
using IPTables.Net.Iptables.TableSync;
using IPTables.Net.TestFramework;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- class IpTablesBinarySyncChainTests
+ public class IpTablesBinarySyncChainTests
{
- [Test]
+ [Fact]
public void TestAdd()
{
var mock = new MockIptablesSystemFactory();
@@ -38,7 +36,7 @@ public void TestAdd()
mock.TestSync(system.GetTableAdapter(4), rulesOriginal, rulesNew, sync, expectedCommands);
}
- [Test]
+ [Fact]
public void TestSimpleDoNothing()
{
var mock = new MockIptablesSystemFactory();
@@ -60,7 +58,7 @@ public void TestSimpleDoNothing()
mock.TestSync(system.GetTableAdapter(4), rulesOriginal, rulesNew, sync, expectedCommands);
}
- [Test]
+ [Fact]
public void TestNatDoNothing()
{
var mock = new MockIptablesSystemFactory();
@@ -82,7 +80,7 @@ public void TestNatDoNothing()
mock.TestSync(system.GetTableAdapter(4), rulesOriginal, rulesNew, sync, expectedCommands);
}
- [Test]
+ [Fact]
public void TestAddDuplicate()
{
var mock = new MockIptablesSystemFactory();
@@ -105,7 +103,7 @@ public void TestAddDuplicate()
mock.TestSync(system.GetTableAdapter(4), rulesOriginal, rulesNew, sync, expectedCommands);
}
- [Test]
+ [Fact]
public void TestDelete()
{
var mock = new MockIptablesSystemFactory();
@@ -127,7 +125,7 @@ public void TestDelete()
mock.TestSync(system.GetTableAdapter(4), rulesOriginal, rulesNew, sync, expectedCommands);
}
- [Test]
+ [Fact]
public void TestDeleteMultiples()
{
var mock = new MockIptablesSystemFactory();
@@ -150,7 +148,7 @@ public void TestDeleteMultiples()
mock.TestSync(system.GetTableAdapter(4), rulesOriginal, rulesNew, sync, expectedCommands);
}
- [Test]
+ [Fact]
public void TestInsertMiddle()
{
var mock = new MockIptablesSystemFactory();
@@ -196,7 +194,7 @@ static bool CommentComparer(IpTablesRule rule1, IpTablesRule rule2)
return comment1.CommentText == comment2.CommentText;
}
- [Test]
+ [Fact]
public void TestUpdateEnd()
{
var mock = new MockIptablesSystemFactory();
@@ -222,7 +220,7 @@ public void TestUpdateEnd()
mock.TestSync(system.GetTableAdapter(4), rulesOriginal, rulesNew, sync, expectedCommands);
}
- [Test]
+ [Fact]
public void TestUpdateBegin()
{
var mock = new MockIptablesSystemFactory();
@@ -248,7 +246,7 @@ public void TestUpdateBegin()
mock.TestSync(system.GetTableAdapter(4), rulesOriginal, rulesNew, sync, expectedCommands);
}
- [Test]
+ [Fact]
public void TestUpdateMiddle()
{
var mock = new MockIptablesSystemFactory();
diff --git a/IPTables.Net.Tests/IpTablesComparisonTests.cs b/IPTables.Net.Tests/IpTablesComparisonTests.cs
index a6c5dd2..e6eec9e 100644
--- a/IPTables.Net.Tests/IpTablesComparisonTests.cs
+++ b/IPTables.Net.Tests/IpTablesComparisonTests.cs
@@ -4,21 +4,19 @@
using System.Net;
using System.Text;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- class IpTablesComparisonTests
+ public class IpTablesComparisonTests
{
- [Test]
+ [Fact]
public void TestIpCompare()
{
- Assert.AreEqual(IPAddress.IPv6Loopback, IPAddress.Parse("::1"));
- Assert.AreEqual(IPAddress.Parse("::0.0.0.1"), IPAddress.Parse("::1"));
+ Assert.Equal(IPAddress.IPv6Loopback, IPAddress.Parse("::1"));
+ Assert.Equal(IPAddress.Parse("::0.0.0.1"), IPAddress.Parse("::1"));
}
- [Test]
+ [Fact]
public void TestComparisonMultiport()
{
String rule = "-A INPUT -p tcp -j RETURN -m multiport --dports 79,22 -m comment --comment TCP";
@@ -27,10 +25,10 @@ public void TestComparisonMultiport()
IpTablesRule r1 = IpTablesRule.Parse(rule, null, chains, 4);
IpTablesRule r2 = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.IsTrue(r1.Compare(r2));
+ Assert.True(r1.Compare(r2));
}
- [Test]
+ [Fact]
public void TestLimitComparison()
{
String rule = "-A INPUT -m limit --limit 100/second --limit-burst 7";
@@ -38,14 +36,14 @@ public void TestLimitComparison()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
IpTablesRule irule2 = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.IsTrue(irule2.Compare(irule));
+ Assert.True(irule2.Compare(irule));
}
- [Test]
+ [Fact]
public void TestDifficultCharacters()
{
String rule = "-A kY9xlwGhPJW6N1QCHoRg -t mangle -p tcp -d 107.1.107.1 -g x_ComPlex -m comment --comment 'ABC||+sPeC14l=|1' -m tcp --dport 81";
@@ -53,11 +51,11 @@ public void TestDifficultCharacters()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
IpTablesRule irule2 = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.IsTrue(irule2.Compare(irule));
+ Assert.True(irule2.Compare(irule));
}
}
}
diff --git a/IPTables.Net.Tests/IpTablesRestoreSyncTests.cs b/IPTables.Net.Tests/IpTablesRestoreSyncTests.cs
index c7e4be1..f031071 100644
--- a/IPTables.Net.Tests/IpTablesRestoreSyncTests.cs
+++ b/IPTables.Net.Tests/IpTablesRestoreSyncTests.cs
@@ -9,18 +9,16 @@
using IPTables.Net.Iptables.TableSync;
using IPTables.Net.TestFramework;
using IPTables.Net.TestFramework.IpTablesRestore;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- class IpTablesRestoreSyncTests
+ public class IpTablesRestoreSyncTests
{
internal void TestApply(IpTablesRuleSet rulesOrig, IpTablesRuleSet rulesSynced, IpTablesRuleSet rulesNew, List commands)
{
try
{
- Assert.AreEqual(rulesNew, rulesSynced);
+ Assert.Equal(rulesNew, rulesSynced);
}
catch
{
@@ -53,7 +51,7 @@ internal void TestApply(IpTablesRuleSet rulesOrig, IpTablesRuleSet rulesSynced,
try
{
- Assert.AreEqual(rulesNew, rulesOrig);
+ Assert.Equal(rulesNew, rulesOrig);
}
catch
{
@@ -73,7 +71,7 @@ private void DumpRuleset(IpTablesRuleSet rulesOrig)
}
}
- [Test]
+ [Fact]
public void TestQuotes()
{
var mock = new MockIptablesSystemFactory();
@@ -97,13 +95,13 @@ public void TestQuotes()
var sync = new DefaultRuleSync();
var rulesSynced = rulesOriginal.DeepClone();
mock.TestSync(client, rulesSynced, rulesNew, sync);
- CollectionAssert.AreEqual(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
+ Assert.Equal(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
TestApply(rulesOriginal, rulesSynced, rulesNew, expectedCommands);
}
}
- [Test]
+ [Fact]
public void TestAddFromEmpty()
{
var mock = new MockIptablesSystemFactory();
@@ -126,14 +124,14 @@ public void TestAddFromEmpty()
var sync = new DefaultRuleSync();
var rulesSynced = rulesOriginal.DeepClone();
mock.TestSync(client, rulesSynced, rulesNew, sync);
- CollectionAssert.AreEqual(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
+ Assert.Equal(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
TestApply(rulesOriginal, rulesSynced, rulesNew, expectedCommands);
}
}
- [Test]
+ [Fact]
public void TestAddAdditional()
{
var mock = new MockIptablesSystemFactory();
@@ -158,13 +156,13 @@ public void TestAddAdditional()
var sync = new DefaultRuleSync();
var rulesSynced = rulesOriginal.DeepClone();
mock.TestSync(client, rulesSynced, rulesNew, sync);
- CollectionAssert.AreEqual(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
+ Assert.Equal(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
TestApply(rulesOriginal, rulesSynced, rulesNew, expectedCommands);
}
}
- [Test]
+ [Fact]
public void TestSimpleDoNothing()
{
var mock = new MockIptablesSystemFactory();
@@ -188,13 +186,13 @@ public void TestSimpleDoNothing()
var sync = new DefaultRuleSync();
var rulesSynced = rulesOriginal.DeepClone();
mock.TestSync(client, rulesSynced, rulesNew, sync);
- CollectionAssert.AreEqual(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
+ Assert.Equal(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
TestApply(rulesOriginal, rulesSynced, rulesNew, expectedCommands);
}
}
- [Test]
+ [Fact]
public void TestNatDoNothing()
{
var mock = new MockIptablesSystemFactory();
@@ -218,13 +216,13 @@ public void TestNatDoNothing()
var sync = new DefaultRuleSync();
var rulesSynced = rulesOriginal.DeepClone();
mock.TestSync(client, rulesSynced, rulesNew, sync);
- CollectionAssert.AreEqual(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
+ Assert.Equal(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
TestApply(rulesOriginal, rulesSynced, rulesNew, expectedCommands);
}
}
- [Test]
+ [Fact]
public void TestAddDuplicate()
{
var mock = new MockIptablesSystemFactory();
@@ -249,13 +247,13 @@ public void TestAddDuplicate()
var sync = new DefaultRuleSync();
var rulesSynced = rulesOriginal.DeepClone();
mock.TestSync(client, rulesSynced, rulesNew, sync);
- CollectionAssert.AreEqual(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
+ Assert.Equal(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
TestApply(rulesOriginal, rulesSynced, rulesNew, expectedCommands);
}
}
- [Test]
+ [Fact]
public void TestDelete()
{
var mock = new MockIptablesSystemFactory();
@@ -278,13 +276,13 @@ public void TestDelete()
var sync = new DefaultRuleSync();
var rulesSynced = rulesOriginal.DeepClone();
mock.TestSync(client, rulesSynced, rulesNew, sync);
- CollectionAssert.AreEqual(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
+ Assert.Equal(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
TestApply(rulesOriginal, rulesSynced, rulesNew, expectedCommands);
}
}
- [Test]
+ [Fact]
public void TestDeleteMultiplesStart()
{
var mock = new MockIptablesSystemFactory();
@@ -307,11 +305,11 @@ public void TestDeleteMultiplesStart()
{
var sync = new DefaultRuleSync();
mock.TestSync(client, rulesOriginal, rulesNew, sync);
- CollectionAssert.AreEqual(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
+ Assert.Equal(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
}
}
- [Test]
+ [Fact]
public void TestDeleteMultiplesEnd()
{
var mock = new MockIptablesSystemFactory();
@@ -336,14 +334,14 @@ public void TestDeleteMultiplesEnd()
var sync = new DefaultRuleSync();
var rulesSynced = rulesOriginal.DeepClone();
mock.TestSync(client, rulesSynced, rulesNew, sync);
- CollectionAssert.AreEqual(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
+ Assert.Equal(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
TestApply(rulesOriginal, rulesSynced, rulesNew, expectedCommands);
}
}
- [Test]
+ [Fact]
public void TestDeleteMultiplesMiddle()
{
var mock = new MockIptablesSystemFactory();
@@ -370,14 +368,14 @@ public void TestDeleteMultiplesMiddle()
var sync = new DefaultRuleSync();
var rulesSynced = rulesOriginal.DeepClone();
mock.TestSync(client, rulesSynced, rulesNew, sync);
- CollectionAssert.AreEqual(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
+ Assert.Equal(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
TestApply(rulesOriginal, rulesSynced, rulesNew, expectedCommands);
}
}
- [Test]
+ [Fact]
public void TestDeleteMultiplesMiddleSplit()
{
var mock = new MockIptablesSystemFactory();
@@ -406,7 +404,7 @@ public void TestDeleteMultiplesMiddleSplit()
var sync = new DefaultRuleSync();
var rulesSynced = rulesOriginal.DeepClone();
mock.TestSync(client, rulesSynced, rulesNew, sync);
- CollectionAssert.AreEqual(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
+ Assert.Equal(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
TestApply(rulesOriginal, rulesSynced, rulesNew, expectedCommands);
}
@@ -414,7 +412,7 @@ public void TestDeleteMultiplesMiddleSplit()
- [Test]
+ [Fact]
public void TestInsertMiddle()
{
var mock = new MockIptablesSystemFactory();
@@ -444,7 +442,7 @@ public void TestInsertMiddle()
var sync = new DefaultRuleSync();
var rulesSynced = rulesOriginal.DeepClone();
mock.TestSync(client, rulesSynced, rulesNew, sync);
- CollectionAssert.AreEqual(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
+ Assert.Equal(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
TestApply(rulesOriginal, rulesSynced, rulesNew, expectedCommands);
}
@@ -467,7 +465,7 @@ static bool CommentComparer(IpTablesRule rule1, IpTablesRule rule2)
return comment1.CommentText == comment2.CommentText;
}
- [Test]
+ [Fact]
public void TestUpdateEnd()
{
var mock = new MockIptablesSystemFactory();
@@ -494,13 +492,13 @@ public void TestUpdateEnd()
var sync = new DefaultRuleSync();
var rulesSynced = rulesOriginal.DeepClone();
mock.TestSync(client, rulesSynced, rulesNew, sync);
- CollectionAssert.AreEqual(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
+ Assert.Equal(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
TestApply(rulesOriginal, rulesSynced, rulesNew, expectedCommands);
}
}
- [Test]
+ [Fact]
public void TestUpdateBegin()
{
var mock = new MockIptablesSystemFactory();
@@ -527,13 +525,13 @@ public void TestUpdateBegin()
var sync = new DefaultRuleSync();
var rulesSynced = rulesOriginal.DeepClone();
mock.TestSync(client, rulesSynced, rulesNew, sync);
- CollectionAssert.AreEqual(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
+ Assert.Equal(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
TestApply(rulesOriginal, rulesSynced, rulesNew, expectedCommands);
}
}
- [Test]
+ [Fact]
public void TestUpdateMiddle()
{
var mock = new MockIptablesSystemFactory();
@@ -562,13 +560,13 @@ public void TestUpdateMiddle()
var sync = new DefaultRuleSync();
var rulesSynced = rulesOriginal.DeepClone();
mock.TestSync(client, rulesSynced, rulesNew, sync);
- CollectionAssert.AreEqual(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
+ Assert.Equal(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
TestApply(rulesOriginal, rulesSynced, rulesNew, expectedCommands);
}
}
- [Test]
+ [Fact]
public void TestUpdateUnlabelled()
{
var mock = new MockIptablesSystemFactory();
@@ -601,14 +599,14 @@ public void TestUpdateUnlabelled()
var rulesSynced = rulesOriginal.DeepClone();
mock.TestSync(client, rulesSynced, rulesNew, sync);
var output = (client as IMockIpTablesRestoreGetOutput).GetOutput();
- CollectionAssert.AreEqual(expectedCommands, output);
+ Assert.Equal(expectedCommands, output);
TestApply(rulesOriginal, rulesSynced, rulesNew, expectedCommands);
}
}
- [Test]
+ [Fact]
public void TestUpdateMiddleTwo()
{
var mock = new MockIptablesSystemFactory();
@@ -643,14 +641,14 @@ public void TestUpdateMiddleTwo()
var sync = new DefaultRuleSync();
var rulesSynced = rulesOriginal.DeepClone();
mock.TestSync(client, rulesSynced, rulesNew, sync);
- CollectionAssert.AreEqual(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
+ Assert.Equal(expectedCommands, (client as IMockIpTablesRestoreGetOutput).GetOutput());
TestApply(rulesOriginal, rulesSynced, rulesNew, expectedCommands);
}
}
- [Test]
+ [Fact]
public void TestDeleteAndUpdate()
{
var mock = new MockIptablesSystemFactory();
@@ -676,7 +674,7 @@ public void TestDeleteAndUpdate()
var sync = new DefaultRuleSync(CommentComparer);
mock.TestSync(client, rulesOriginal, rulesNew, sync);
var commands = (client as IMockIpTablesRestoreGetOutput).GetOutput().ToList();
- Assert.AreEqual(5, commands.Count);
+ Assert.Equal(5, commands.Count);
Assert.True(commands[1].StartsWith("-D INPUT 1"));
Assert.True(commands[2].StartsWith("-R INPUT 1"));
Assert.True(commands[3].StartsWith("-R INPUT 2"));
diff --git a/IPTables.Net.Tests/IpTablesRuleSetTests.cs b/IPTables.Net.Tests/IpTablesRuleSetTests.cs
index 95c0d29..346abe9 100644
--- a/IPTables.Net.Tests/IpTablesRuleSetTests.cs
+++ b/IPTables.Net.Tests/IpTablesRuleSetTests.cs
@@ -3,14 +3,12 @@
using System.Linq;
using System.Text;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- class IpTablesRuleSetTests
+ public class IpTablesRuleSetTests
{
- [Test]
+ [Fact]
public void TestAddChain()
{
IpTablesRuleSet ruleSet = new IpTablesRuleSet(4,null);
@@ -21,12 +19,12 @@ public void TestAddChain()
ruleSet.AddRule(irule);
- Assert.AreEqual(1, ruleSet.Chains.Count());
- Assert.AreEqual("filter", ruleSet.Chains.First().Table);
- Assert.AreEqual(1, ruleSet.Chains.First().Rules.Count());
+ Assert.Equal(1, ruleSet.Chains.Count());
+ Assert.Equal("filter", ruleSet.Chains.First().Table);
+ Assert.Equal(1, ruleSet.Chains.First().Rules.Count());
}
- [Test]
+ [Fact]
public void TestAddChainTwoRules()
{
IpTablesRuleSet ruleSet = new IpTablesRuleSet(4,null);
@@ -37,17 +35,17 @@ public void TestAddChainTwoRules()
ruleSet.AddRule(irule);
- Assert.AreEqual(1, ruleSet.Chains.Count());
- Assert.AreEqual("filter", ruleSet.Chains.First().Table);
- Assert.AreEqual(1, ruleSet.Chains.First().Rules.Count());
+ Assert.Equal(1, ruleSet.Chains.Count());
+ Assert.Equal("filter", ruleSet.Chains.First().Table);
+ Assert.Equal(1, ruleSet.Chains.First().Rules.Count());
ruleSet.AddRule(irule);
- Assert.AreEqual(1, ruleSet.Chains.Count());
- Assert.AreEqual(2, ruleSet.Chains.First().Rules.Count());
+ Assert.Equal(1, ruleSet.Chains.Count());
+ Assert.Equal(2, ruleSet.Chains.First().Rules.Count());
}
- [Test]
+ [Fact]
public void TestAddChains()
{
IpTablesRuleSet ruleSet = new IpTablesRuleSet(4,null);
@@ -58,19 +56,19 @@ public void TestAddChains()
ruleSet.AddRule(irule);
- Assert.AreEqual(1, ruleSet.Chains.Count());
- Assert.AreEqual("filter", ruleSet.Chains.First().Table);
- Assert.AreEqual(1, ruleSet.Chains.First().Rules.Count());
+ Assert.Equal(1, ruleSet.Chains.Count());
+ Assert.Equal("filter", ruleSet.Chains.First().Table);
+ Assert.Equal(1, ruleSet.Chains.First().Rules.Count());
rule = "-A OUTPUT -p tcp -j DROP -m connlimit --connlimit-above 10";
irule = IpTablesRule.Parse(rule, null, chains, 4);
ruleSet.AddRule(irule);
- Assert.AreEqual(2, ruleSet.Chains.Count());
- Assert.AreEqual(1, ruleSet.Chains.First().Rules.Count());
- Assert.AreEqual(1, ruleSet.Chains.Skip(1).First().Rules.Count());
- Assert.AreEqual("filter", ruleSet.Chains.Skip(1).First().Table);
+ Assert.Equal(2, ruleSet.Chains.Count());
+ Assert.Equal(1, ruleSet.Chains.First().Rules.Count());
+ Assert.Equal(1, ruleSet.Chains.Skip(1).First().Rules.Count());
+ Assert.Equal("filter", ruleSet.Chains.Skip(1).First().Table);
}
}
}
diff --git a/IPTables.Net.Tests/IpTablesSaveReadingTests.cs b/IPTables.Net.Tests/IpTablesSaveReadingTests.cs
index 06a70b8..4a00959 100644
--- a/IPTables.Net.Tests/IpTablesSaveReadingTests.cs
+++ b/IPTables.Net.Tests/IpTablesSaveReadingTests.cs
@@ -5,16 +5,14 @@
using IPTables.Net.Iptables.Adapter;
using IPTables.Net.Iptables.Adapter.Client;
using IPTables.Net.Iptables.Adapter.Client.Helper;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class IpTablesSaveReadingTests
+ public class IpTablesSaveReadingTests
{
private static readonly IpTablesSystem System = new IpTablesSystem(null, new IPTablesBinaryAdapter());
- [Test]
+ [Fact]
public void TestParseBlocklist()
{
String toParse =
@@ -22,10 +20,10 @@ public void TestParseBlocklist()
var rules = IPTablesSaveParser.GetRulesFromOutput(System, toParse, "filter", 4);
- Assert.AreEqual(3, rules.Chains.Count());
+ Assert.Equal(3, rules.Chains.Count());
}
- [Test]
+ [Fact]
public void TestParseEmpty()
{
String toParse =
@@ -33,13 +31,13 @@ public void TestParseEmpty()
var rules = IPTablesSaveParser.GetRulesFromOutput(System, toParse, "filter", 4);
- Assert.AreEqual(3, rules.Chains.Count());
- Assert.AreEqual(0, rules.Chains.ElementAt(0).Rules.Count);
- Assert.AreEqual(0, rules.Chains.ElementAt(1).Rules.Count);
- Assert.AreEqual(0, rules.Chains.ElementAt(2).Rules.Count);
+ Assert.Equal(3, rules.Chains.Count());
+ Assert.Equal(0, rules.Chains.ElementAt(0).Rules.Count);
+ Assert.Equal(0, rules.Chains.ElementAt(1).Rules.Count);
+ Assert.Equal(0, rules.Chains.ElementAt(2).Rules.Count);
}
- [Test]
+ [Fact]
public static void TestParsePortForward()
{
String toParse =
@@ -47,8 +45,8 @@ public static void TestParsePortForward()
var rules = IPTablesSaveParser.GetRulesFromOutput(System, toParse, "nat", 4);
- Assert.AreEqual(1, rules.GetChainOrDefault("PREROUTING", "nat").Rules.Count);
- Assert.AreEqual(1, rules.GetChainOrDefault("POSTROUTING", "nat").Rules.Count);
+ Assert.Equal(1, rules.GetChainOrDefault("PREROUTING", "nat").Rules.Count);
+ Assert.Equal(1, rules.GetChainOrDefault("POSTROUTING", "nat").Rules.Count);
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/IpUtilsRouteTests.cs b/IPTables.Net.Tests/IpUtilsRouteTests.cs
index afbc004..aea0921 100644
--- a/IPTables.Net.Tests/IpUtilsRouteTests.cs
+++ b/IPTables.Net.Tests/IpUtilsRouteTests.cs
@@ -8,14 +8,12 @@
using IPTables.Net.IpUtils;
using IPTables.Net.IpUtils.Utils;
using IPTables.Net.TestFramework;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- class IpUtilsRouteTests
+ public class IpUtilsRouteTests
{
- [Test]
+ [Fact]
public void TestParseRule()
{
var systemFactory = new MockIptablesSystemFactory();
@@ -24,7 +22,7 @@ public void TestParseRule()
var two = ipUtils.ParseObjectInternal("10.128.1.0/24 dev tap0 proto kernel scope link src 10.128.1.201", "to");
}
- [Test]
+ [Fact]
public void TestParseRuleLocal()
{
var systemFactory = new MockIptablesSystemFactory();
@@ -32,7 +30,7 @@ public void TestParseRuleLocal()
var one = ipUtils.ParseObjectInternal("local default dev lo table 100 scope host", "to");
ipUtils.ExportObject(one);
}
- [Test]
+ [Fact]
public void TestParseRuleAnycastV6()
{
var systemFactory = new MockIptablesSystemFactory();
diff --git a/IPTables.Net.Tests/IpUtilsRuleTests.cs b/IPTables.Net.Tests/IpUtilsRuleTests.cs
index 61af286..aa9073f 100644
--- a/IPTables.Net.Tests/IpUtilsRuleTests.cs
+++ b/IPTables.Net.Tests/IpUtilsRuleTests.cs
@@ -9,14 +9,12 @@
using IPTables.Net.IpUtils.Utils;
using IPTables.Net.TestFramework;
using Microsoft.VisualStudio.TestPlatform.Utilities;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- class IpUtilsRuleTests
+ public class IpUtilsRuleTests
{
- [Test]
+ [Fact]
public void TestParseRule()
{
var systemFactory = new MockIptablesSystemFactory(true);
@@ -24,12 +22,12 @@ public void TestParseRule()
var one = ipUtils.ParseObjectInternal("default via 10.17.199.1 dev s4 table 200", "to");
var two = ipUtils.ParseObjectInternal("default via 10.17.199.1 dev s4 table 200", "to");
- CollectionAssert.AreEqual(one.Pairs, two.Pairs);
- Assert.AreEqual("default", one.Pairs["to"]);
- Assert.AreEqual("200",one.Pairs["table"]);
+ Assert.Equal(one.Pairs, two.Pairs);
+ Assert.Equal("default", one.Pairs["to"]);
+ Assert.Equal("200",one.Pairs["table"]);
}
- [Test]
+ [Fact]
public void TestParsePref()
{
var systemFactory = new MockIptablesSystemFactory(true);
@@ -37,7 +35,7 @@ public void TestParsePref()
var one = ipUtils.ParseObject("0: from all fwmark 0x1000200/0x1ffff00 lookup 15002");
}
- [Test]
+ [Fact]
public void TestAddRule()
{
var systemFactory = new MockIptablesSystemFactory(true);
@@ -50,10 +48,10 @@ public void TestAddRule()
new KeyValuePair ("ip","rule add from 1.1.1.1 lookup 100")
};
- CollectionAssert.AreEqual(expected, systemFactory.ExecutionLog);
+ Assert.Equal(expected, systemFactory.ExecutionLog);
}
- [Test]
+ [Fact]
public void TestAddRule2()
{
var systemFactory = new MockIptablesSystemFactory(true);
@@ -66,10 +64,10 @@ public void TestAddRule2()
new KeyValuePair ("ip","rule add not from 1.1.1.1 lookup 100")
};
- CollectionAssert.AreEqual(expected, systemFactory.ExecutionLog);
+ Assert.Equal(expected, systemFactory.ExecutionLog);
}
- [Test]
+ [Fact]
public void TestAddObjRule()
{
var systemFactory = new MockIptablesSystemFactory(true);
@@ -89,10 +87,10 @@ public void TestAddObjRule()
new KeyValuePair ("ip","rule add not from 1.1.1.1 lookup 100")
};
- CollectionAssert.AreEqual(expected, systemFactory.ExecutionLog);
+ Assert.Equal(expected, systemFactory.ExecutionLog);
}
- [Test]
+ [Fact]
public void TestDeleteRule()
{
var systemFactory = new MockIptablesSystemFactory(true);
@@ -105,10 +103,10 @@ public void TestDeleteRule()
new KeyValuePair ("ip","rule delete from 1.1.1.1 lookup 100")
};
- CollectionAssert.AreEqual(expected, systemFactory.ExecutionLog);
+ Assert.Equal(expected, systemFactory.ExecutionLog);
}
- [Test]
+ [Fact]
public void TestDeleteRuleId()
{
var systemFactory = new MockIptablesSystemFactory(true);
@@ -124,10 +122,10 @@ public void TestDeleteRuleId()
new KeyValuePair ("ip","rule delete pref 100 from 1.1.1.1")
};
- CollectionAssert.AreEqual(expected, systemFactory.ExecutionLog);
+ Assert.Equal(expected, systemFactory.ExecutionLog);
}
- [Test]
+ [Fact]
public void TestGetRules()
{
var systemFactory = new MockIptablesSystemFactory(true);
@@ -136,9 +134,9 @@ public void TestGetRules()
var ipUtils = new IpRuleController(systemFactory);
var rules = ipUtils.GetAll();
- Assert.AreEqual(2, rules.Count);
- Assert.AreEqual("pref 32766 from all lookup main", string.Join(" ", ipUtils.ExportObject(rules[0])));
- Assert.AreEqual("pref 32767 from all lookup default", string.Join(" ", ipUtils.ExportObject(rules[1])));
+ Assert.Equal(2, rules.Count);
+ Assert.Equal("pref 32766 from all lookup main", string.Join(" ", ipUtils.ExportObject(rules[0])));
+ Assert.Equal("pref 32767 from all lookup default", string.Join(" ", ipUtils.ExportObject(rules[1])));
}
}
}
diff --git a/IPTables.Net.Tests/IptablesLibraryTest.cs b/IPTables.Net.Tests/IptablesLibraryTest.cs
index c6f43ce..89e85ea 100644
--- a/IPTables.Net.Tests/IptablesLibraryTest.cs
+++ b/IPTables.Net.Tests/IptablesLibraryTest.cs
@@ -1,197 +1,141 @@
using System;
-using System.Collections.Generic;
using System.Diagnostics;
-using System.IO;
using System.Linq;
-using System.Text;
using IPTables.Net.Iptables;
using IPTables.Net.Iptables.Adapter;
using IPTables.Net.Iptables.Adapter.Client;
using IPTables.Net.Iptables.NativeLibrary;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [NonParallelizable]
- [TestFixture(4)]
- //[TestFixture(6)]
- class IptablesLibraryTest
+ public sealed class IptablesLibraryFixture : IDisposable
{
- private int _ipVersion;
+ public int IpVersion => IptablesSystemTestSupport.IpVersion;
- public static bool IsLinux
+ public string SkipReason { get; }
+
+ public IptablesLibraryFixture()
{
- get
+ SkipReason = TestEnvironment.GetLinuxSystemTestSkipReason();
+ if (SkipReason != null)
{
- int p = (int)Environment.OSVersion.Platform;
- return (p == 4) || (p == 6) || (p == 128);
+ return;
}
+
+ var binary = GetBinary();
+ IptablesSystemTestSupport.CleanupTestChains(binary);
+ IptablesSystemTestSupport.RequireSuccess(binary, "-N test2");
+ IptablesSystemTestSupport.RequireSuccess(binary, "-N test");
+ IptablesSystemTestSupport.RequireSuccess(binary, "-A test -j ACCEPT");
+ IptablesSystemTestSupport.RequireSuccess(binary, "-N test3");
+ IptablesSystemTestSupport.RequireSuccess(binary, "-A test3 -p tcp -m tcp --dport 80 -j ACCEPT");
}
- public IptablesLibraryTest(int ipVersion)
+ public string GetBinary()
{
- _ipVersion = ipVersion;
+ return IptablesSystemTestSupport.GetBinary(IpVersion);
}
-
- private String GetBinaryName()
+ public void SkipIfNeeded()
{
- if (_ipVersion == 4)
+ if (SkipReason != null)
{
- return "iptables";
+ Assert.Skip(SkipReason);
}
- return "ip6tables";
}
- private String GetBinary()
+ public void Dispose()
{
- var name = GetBinaryName();
- if (Path.Exists("/sbin/" + name)) return "/sbin/" + name;
- if (Path.Exists("/usr/sbin/" + name)) return "/usr/sbin/" + name;
- return name;
+ if (SkipReason != null)
+ {
+ return;
+ }
+
+ IptablesSystemTestSupport.CleanupTestChains(GetBinary());
}
+ }
- [OneTimeSetUp]
- public void TestStartup()
- {
- if (IsLinux)
- {
- if (Environment.GetEnvironmentVariable("SKIP_SYSTEM_TESTS") == "1")
- {
- Assert.Ignore();
- }
+ [Collection(SystemIptablesCollectionDefinition.Name)]
+ public class IptablesLibraryTest : IClassFixture
+ {
+ private readonly IptablesLibraryFixture _fixture;
- var binary = GetBinary();
- CleanupTestChains(binary);
- RequireSuccess(binary, "-N test2");
- RequireSuccess(binary, "-N test");
- RequireSuccess(binary, "-A test -j ACCEPT");
- RequireSuccess(binary, "-N test3");
- RequireSuccess(binary, "-A test3 -p tcp -m tcp --dport 80 -j ACCEPT");
- }
+ public IptablesLibraryTest(IptablesLibraryFixture fixture)
+ {
+ _fixture = fixture;
}
- private int Execute(string binary, string args, bool logOutput = true)
+ [Fact]
+ public void TestRuleOutput()
{
- using (var process = Process.Start(new ProcessStartInfo(binary, args)
- {
- RedirectStandardError = true,
- RedirectStandardOutput = true,
- UseShellExecute = false
- }))
+ _fixture.SkipIfNeeded();
+
+ Assert.Equal(0, IptcInterface.RefCount);
+ var system = new IpTablesSystem(null, new IPTablesLibAdapter());
+ using (var client = system.GetTableAdapter(_fixture.IpVersion))
{
- var standardOutput = process.StandardOutput.ReadToEnd();
- var standardError = process.StandardError.ReadToEnd();
- process.WaitForExit();
+ Assert.True(client is IPTablesLibAdapterClient);
+ var rules = client.ListRules("filter");
+ Assert.NotNull(rules);
- if (logOutput)
+ foreach (var chain in rules.Chains)
{
- if (!string.IsNullOrWhiteSpace(standardOutput))
- {
- Console.WriteLine(standardOutput);
- }
-
- if (!string.IsNullOrWhiteSpace(standardError))
- {
- Console.Error.WriteLine(standardError);
- }
+ Assert.True(chain.IpVersion == _fixture.IpVersion, "Incorrect IP Version for chain: " + chain);
}
- return process.ExitCode;
+ Assert.True(rules.Chains.SelectMany(a => a.Rules).Any(), "Expected at least one rule");
+
+ foreach (var rule in rules.Chains.SelectMany(a => a.Rules))
+ {
+ Assert.True(rule.IpVersion == _fixture.IpVersion, "Incorrect IP Version for rule: " + rule);
+ }
}
+ Assert.Equal(0, IptcInterface.RefCount);
}
- private void RequireSuccess(string binary, string args)
+ [Fact]
+ public void TestRuleAdd()
{
- Assert.That(Execute(binary, args), Is.EqualTo(0), "Command should succeed: " + binary + " " + args);
- }
+ _fixture.SkipIfNeeded();
- private void CleanupTestChains(string binary)
- {
- foreach (var chain in new[] {"test", "test2", "test3"})
+ Assert.Equal(0, IptcInterface.RefCount);
+ var system = new IpTablesSystem(null, new IPTablesLibAdapter());
+ using (var client = system.GetTableAdapter(_fixture.IpVersion))
{
- Execute(binary, "-F " + chain, false);
- Execute(binary, "-X " + chain, false);
- }
- }
+ Assert.True(client is IPTablesLibAdapterClient);
+ var rules = client.ListRules("filter");
+ Assert.NotNull(rules);
- [OneTimeTearDown]
- public void TestDestroy()
- {
- if (IsLinux)
- {
- if (Environment.GetEnvironmentVariable("SKIP_SYSTEM_TESTS") == "1")
+ var chain = new IpTablesChainSet(_fixture.IpVersion);
+ foreach (var existingChain in rules.Chains)
{
- return;
+ Assert.Equal(_fixture.IpVersion, existingChain.IpVersion);
+ chain.AddChain(existingChain as IpTablesChain);
}
- var binary = GetBinary();
- CleanupTestChains(binary);
- }
- }
-
- [Test]
- public void TestRuleOutput()
- {
- if (IsLinux)
- {
- Assert.AreEqual(0, IptcInterface.RefCount);
- var system = new IpTablesSystem(null, new IPTablesLibAdapter());
- using (var client = system.GetTableAdapter(_ipVersion))
+ var rule = IpTablesRule.Parse("-A test2 -p 80 -j ACCEPT", system, chain);
+ client.StartTransaction();
+ try
{
- Assert.IsTrue(client is IPTablesLibAdapterClient);
- var rules = client.ListRules("filter");
- Assert.IsTrue(rules != null, "Expected to find filter table");
- foreach (var chain in rules.Chains)
- {
- Assert.AreEqual(_ipVersion, chain.IpVersion, "Incorrect IP Version for chain: " + chain);
- }
- Assert.AreNotEqual(0, rules.Chains.SelectMany((a)=>a.Rules).Count());
- foreach (var rule in rules.Chains.SelectMany((a) => a.Rules))
- {
- Assert.AreEqual(_ipVersion, rule.IpVersion, "Incorrect IP Version for rule: " + rule);
- }
+ client.AddRule(rule);
+ }
+ finally
+ {
+ client.EndTransactionCommit();
}
- Assert.AreEqual(0, IptcInterface.RefCount);
- }
- }
-
- [Test]
- public void TestRuleAdd()
- {
- if (IsLinux)
- {
- Assert.AreEqual(0, IptcInterface.RefCount);
- var system = new IpTablesSystem(null, new IPTablesLibAdapter());
- using (var client = system.GetTableAdapter(_ipVersion))
+ using (var process = Process.Start(new ProcessStartInfo(_fixture.GetBinary(), "-L test2")
+ {
+ RedirectStandardOutput = true,
+ UseShellExecute = false
+ }))
{
- Assert.IsTrue(client is IPTablesLibAdapterClient);
- var rules = client.ListRules("filter");
- var chain = new IpTablesChainSet(_ipVersion);
- foreach (var c in rules.Chains)
- {
- Assert.AreEqual(_ipVersion, c.IpVersion);
- chain.AddChain(c as IpTablesChain);
- }
- var rule = IpTablesRule.Parse("-A test2 -p 80 -j ACCEPT", system, chain);
- client.StartTransaction();
- try
- {
- client.AddRule(rule);
- }
- finally
- {
- client.EndTransactionCommit();
- }
-
- var proc = Process.Start(new ProcessStartInfo(GetBinary(), "-L test2"){RedirectStandardOutput = true, UseShellExecute = false});
- proc.WaitForExit();
- String listOutput = proc.StandardOutput.ReadToEnd();
- Assert.IsTrue(listOutput.Contains("anywhere"), "must have created rule");
+ process.WaitForExit();
+ string listOutput = process.StandardOutput.ReadToEnd();
+ Assert.True(listOutput.Contains("anywhere"), "must have created rule");
}
- Assert.AreEqual(0, IptcInterface.RefCount);
}
+ Assert.Equal(0, IptcInterface.RefCount);
}
}
}
diff --git a/IPTables.Net.Tests/IptablesSystemTestSupport.cs b/IPTables.Net.Tests/IptablesSystemTestSupport.cs
new file mode 100644
index 0000000..667a2a6
--- /dev/null
+++ b/IPTables.Net.Tests/IptablesSystemTestSupport.cs
@@ -0,0 +1,119 @@
+using System;
+using System.Diagnostics;
+using System.IO;
+
+namespace IPTables.Net.Tests
+{
+ [CollectionDefinition(Name, DisableParallelization = true)]
+ public class SystemIptablesCollectionDefinition
+ {
+ public const string Name = "System iptables";
+ }
+
+ internal static class TestEnvironment
+ {
+ public static bool IsLinux
+ {
+ get
+ {
+ int platform = (int)Environment.OSVersion.Platform;
+ return (platform == 4) || (platform == 6) || (platform == 128);
+ }
+ }
+
+ public static string GetLinuxSystemTestSkipReason()
+ {
+ if (!IsLinux)
+ {
+ return "System tests require Linux.";
+ }
+
+ if (Environment.GetEnvironmentVariable("SKIP_SYSTEM_TESTS") == "1")
+ {
+ return "System tests disabled via SKIP_SYSTEM_TESTS=1.";
+ }
+
+ return null;
+ }
+
+ public static void RequireLinuxSystemTests()
+ {
+ var skipReason = GetLinuxSystemTestSkipReason();
+ if (skipReason != null)
+ {
+ Assert.Skip(skipReason);
+ }
+ }
+ }
+
+ internal static class IptablesSystemTestSupport
+ {
+ public const int IpVersion = 4;
+
+ public static string GetBinaryName(int ipVersion)
+ {
+ return ipVersion == 4 ? "iptables" : "ip6tables";
+ }
+
+ public static string GetBinary(int ipVersion)
+ {
+ var name = GetBinaryName(ipVersion);
+ if (Path.Exists("/sbin/" + name))
+ {
+ return "/sbin/" + name;
+ }
+
+ if (Path.Exists("/usr/sbin/" + name))
+ {
+ return "/usr/sbin/" + name;
+ }
+
+ return name;
+ }
+
+ public static int Execute(string binary, string args, bool logOutput = true)
+ {
+ using (var process = Process.Start(new ProcessStartInfo(binary, args)
+ {
+ RedirectStandardError = true,
+ RedirectStandardOutput = true,
+ UseShellExecute = false
+ }))
+ {
+ var standardOutput = process.StandardOutput.ReadToEnd();
+ var standardError = process.StandardError.ReadToEnd();
+ process.WaitForExit();
+
+ if (logOutput)
+ {
+ if (!string.IsNullOrWhiteSpace(standardOutput))
+ {
+ Console.WriteLine(standardOutput);
+ }
+
+ if (!string.IsNullOrWhiteSpace(standardError))
+ {
+ Console.Error.WriteLine(standardError);
+ }
+ }
+
+ return process.ExitCode;
+ }
+ }
+
+ public static void RequireSuccess(string binary, string args)
+ {
+ var exitCode = Execute(binary, args);
+ Assert.True(exitCode == 0, "Command should succeed: " + binary + " " + args);
+ }
+
+ public static void CleanupTestChains(string binary)
+ {
+ foreach (var chain in new[] { "test", "test2", "test3" })
+ {
+ Execute(binary, "-F " + chain, false);
+ Execute(binary, "-X " + chain, false);
+ }
+ }
+ }
+}
diff --git a/IPTables.Net.Tests/IptcInterfaceTest.cs b/IPTables.Net.Tests/IptcInterfaceTest.cs
index afeeb15..50a47b4 100644
--- a/IPTables.Net.Tests/IptcInterfaceTest.cs
+++ b/IPTables.Net.Tests/IptcInterfaceTest.cs
@@ -1,264 +1,194 @@
using System;
using System.Collections.Generic;
-using System.Diagnostics;
-using System.IO;
-using System.Linq;
using System.Net;
-using System.Text;
using IPTables.Net.Iptables.NativeLibrary;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [NonParallelizable]
- [TestFixture(4)]
- //[TestFixture(6)]
- class IptcInterfaceTest
+ public sealed class IptcInterfaceFixture : IDisposable
{
- private int _ipVersion;
+ public int IpVersion => IptablesSystemTestSupport.IpVersion;
- public static bool IsLinux
+ public string SkipReason { get; }
+
+ public IptcInterfaceFixture()
{
- get
+ SkipReason = TestEnvironment.GetLinuxSystemTestSkipReason();
+ if (SkipReason != null)
{
- int p = (int)Environment.OSVersion.Platform;
- return (p == 4) || (p == 6) || (p == 128);
+ return;
}
- }
- public IptcInterfaceTest(int ipVersion)
- {
- _ipVersion = ipVersion;
- }
+ Console.WriteLine("Test Startup");
- private String GetBinaryName()
- {
- if (_ipVersion == 4)
- {
- return "iptables";
- }
- return "ip6tables";
+ var binary = GetBinary();
+ IptablesSystemTestSupport.CleanupTestChains(binary);
+ IptablesSystemTestSupport.RequireSuccess(binary, "-N test2");
+ IptablesSystemTestSupport.RequireSuccess(binary, "-N test");
+ IptablesSystemTestSupport.RequireSuccess(binary, "-A test -j ACCEPT");
+ IptablesSystemTestSupport.RequireSuccess(binary, "-N test3");
+ IptablesSystemTestSupport.RequireSuccess(binary, "-A test3 -p tcp -m tcp --dport 80 -j ACCEPT");
}
- private String GetBinary()
+ public string GetBinary()
{
- var name = GetBinaryName();
- if(Path.Exists("/sbin/"+name)) return "/sbin/"+name;
- if(Path.Exists("/usr/sbin/"+name)) return "/usr/sbin/"+name;
- return name;
+ return IptablesSystemTestSupport.GetBinary(IpVersion);
}
- [OneTimeSetUp]
- public void TestStartup()
+ public void SkipIfNeeded()
{
- if (IsLinux)
+ if (SkipReason != null)
{
- if (Environment.GetEnvironmentVariable("SKIP_SYSTEM_TESTS") == "1")
- {
- Assert.Ignore();
- }
-
- Console.WriteLine("Test Startup");
-
- var binary = GetBinary();
- CleanupTestChains(binary);
- RequireSuccess(binary, "-N test2");
- RequireSuccess(binary, "-N test");
- RequireSuccess(binary, "-A test -j ACCEPT");
- RequireSuccess(binary, "-N test3");
- RequireSuccess(binary, "-A test3 -p tcp -m tcp --dport 80 -j ACCEPT");
+ Assert.Skip(SkipReason);
}
}
- private int Execute(string binary, string args, bool logOutput = true)
+ public void Dispose()
{
- using (var process = Process.Start(new ProcessStartInfo(binary, args)
- {
- RedirectStandardError = true,
- RedirectStandardOutput = true,
- UseShellExecute = false
- }))
+ if (SkipReason != null)
{
- var standardOutput = process.StandardOutput.ReadToEnd();
- var standardError = process.StandardError.ReadToEnd();
- process.WaitForExit();
-
- if (logOutput)
- {
- if (!string.IsNullOrWhiteSpace(standardOutput))
- {
- Console.WriteLine(standardOutput);
- }
-
- if (!string.IsNullOrWhiteSpace(standardError))
- {
- Console.Error.WriteLine(standardError);
- }
- }
-
- return process.ExitCode;
+ return;
}
- }
- private void RequireSuccess(string binary, string args)
- {
- Assert.That(Execute(binary, args), Is.EqualTo(0), "Command should succeed: " + binary + " " + args);
+ Console.WriteLine("Test Done");
+ IptablesSystemTestSupport.CleanupTestChains(GetBinary());
}
+ }
- private void CleanupTestChains(string binary)
- {
- foreach (var chain in new[] {"test", "test2", "test3"})
- {
- Execute(binary, "-F " + chain, false);
- Execute(binary, "-X " + chain, false);
- }
- }
+ [Collection(SystemIptablesCollectionDefinition.Name)]
+ public class IptcInterfaceTest : IClassFixture
+ {
+ private readonly IptcInterfaceFixture _fixture;
- [OneTimeTearDown]
- public void TestDestroy()
+ public IptcInterfaceTest(IptcInterfaceFixture fixture)
{
- if (IsLinux)
- {
- if (Environment.GetEnvironmentVariable("SKIP_SYSTEM_TESTS") == "1")
- {
- return;
- }
- Console.WriteLine("Test Done");
- var binary = GetBinary();
- CleanupTestChains(binary);
- }
+ _fixture = fixture;
}
- [Test]
+ [Fact]
public void TestRuleOutputSimple()
{
- if (IsLinux)
+ _fixture.SkipIfNeeded();
+
+ Assert.Equal(0, IptcInterface.RefCount);
+ using (var iptc = new IptcInterface("filter", _fixture.IpVersion))
{
- Assert.AreEqual(0, IptcInterface.RefCount);
- using (IptcInterface iptc = new IptcInterface("filter", _ipVersion))
- {
- var rules = iptc.GetRules("test");
- Assert.AreEqual(1, rules.Count);
- Assert.AreEqual("-A test -j ACCEPT", iptc.GetRuleString("test", rules[0]));
- }
- Assert.AreEqual(0, IptcInterface.RefCount);
- }
+ var rules = iptc.GetRules("test");
+ Assert.Equal(1, rules.Count);
+ Assert.Equal("-A test -j ACCEPT", iptc.GetRuleString("test", rules[0]));
+ }
+ Assert.Equal(0, IptcInterface.RefCount);
}
- [Test]
+ [Fact]
public void TestRuleOutputModule()
{
- if (IsLinux)
+ _fixture.SkipIfNeeded();
+
+ Assert.Equal(0, IptcInterface.RefCount);
+ using (var iptc = new IptcInterface("filter", _fixture.IpVersion))
{
- Assert.AreEqual(0, IptcInterface.RefCount);
- using (IptcInterface iptc = new IptcInterface("filter", _ipVersion))
- {
- var rules = iptc.GetRules("test3");
- Assert.AreEqual(1, rules.Count);
- Assert.AreEqual("-A test3 -p tcp -m tcp --dport 80 -j ACCEPT", iptc.GetRuleString("test3", rules[0]));
- }
- Assert.AreEqual(0, IptcInterface.RefCount);
+ var rules = iptc.GetRules("test3");
+ Assert.Equal(1, rules.Count);
+ Assert.Equal("-A test3 -p tcp -m tcp --dport 80 -j ACCEPT", iptc.GetRuleString("test3", rules[0]));
}
+ Assert.Equal(0, IptcInterface.RefCount);
}
-
-
- [Test]
+ [Fact]
public void TestRuleInput()
{
- if (IsLinux)
- {
- Assert.AreEqual(0, IptcInterface.RefCount);
- using (IptcInterface iptc = new IptcInterface("filter", _ipVersion))
- {
-
- var status = iptc.ExecuteCommand(_ipVersion == 4 ? "iptables -A test2 -d 1.1.1.1 -p tcp -m tcp --dport 80 -j ACCEPT" : "ip6tables -A test2 -d ::1 -p tcp -m tcp --dport 80 -j ACCEPT");
- Assert.AreEqual(1, status, "Expected OK return value");
+ _fixture.SkipIfNeeded();
- var rules = iptc.GetRules("test2");
- Assert.AreEqual(1, rules.Count);
- Assert.AreEqual(_ipVersion == 4 ? "-A test2 -d 1.1.1.1/32 -p tcp -m tcp --dport 80 -j ACCEPT" : "-A test2 -d ::1/128 -p tcp -m tcp --dport 80 -j ACCEPT",
- iptc.GetRuleString("test2", rules[0]));
- }
- Assert.AreEqual(0, IptcInterface.RefCount);
+ Assert.Equal(0, IptcInterface.RefCount);
+ using (var iptc = new IptcInterface("filter", _fixture.IpVersion))
+ {
+ var status = iptc.ExecuteCommand(_fixture.IpVersion == 4
+ ? "iptables -A test2 -d 1.1.1.1 -p tcp -m tcp --dport 80 -j ACCEPT"
+ : "ip6tables -A test2 -d ::1 -p tcp -m tcp --dport 80 -j ACCEPT");
+ Assert.True(status == 1, "Expected OK return value");
+
+ var rules = iptc.GetRules("test2");
+ Assert.Equal(1, rules.Count);
+ Assert.Equal(
+ _fixture.IpVersion == 4
+ ? "-A test2 -d 1.1.1.1/32 -p tcp -m tcp --dport 80 -j ACCEPT"
+ : "-A test2 -d ::1/128 -p tcp -m tcp --dport 80 -j ACCEPT",
+ iptc.GetRuleString("test2", rules[0]));
}
+ Assert.Equal(0, IptcInterface.RefCount);
}
- [Test]
+ [Fact]
public void TestRuleIp()
{
- if (IsLinux)
+ _fixture.SkipIfNeeded();
+
+ Assert.Equal(0, IptcInterface.RefCount);
+
+ string ip;
+ int cidr;
+ if (_fixture.IpVersion == 4)
+ {
+ ip = IPAddress.Loopback.ToString();
+ cidr = 32;
+ }
+ else
{
- Assert.AreEqual(0, IptcInterface.RefCount);
+ ip = "::1";
+ cidr = 128;
+ }
- String ip;
- int cidr;
- if (_ipVersion == 4)
- {
- ip = IPAddress.Loopback.ToString();
- cidr = 32;
- }
- else
- {
- ip = "::1";
- cidr = 128;
- }
- var rule = "-A test3 -s " + ip + "/" + cidr + " -p tcp -m tcp --dport 80 -j ACCEPT";
+ var rule = "-A test3 -s " + ip + "/" + cidr + " -p tcp -m tcp --dport 80 -j ACCEPT";
- using (IptcInterface iptc = new IptcInterface("filter", _ipVersion))
- {
- iptc.ExecuteCommand("ip6tables " + rule);
- var rules = iptc.GetRules("test3");
- Assert.AreEqual(2, rules.Count);
- Assert.AreEqual(rule, iptc.GetRuleString("test3", rules[1]));
- }
- Assert.AreEqual(0, IptcInterface.RefCount);
+ using (var iptc = new IptcInterface("filter", _fixture.IpVersion))
+ {
+ iptc.ExecuteCommand("ip6tables " + rule);
+ var rules = iptc.GetRules("test3");
+ Assert.Equal(2, rules.Count);
+ Assert.Equal(rule, iptc.GetRuleString("test3", rules[1]));
}
+ Assert.Equal(0, IptcInterface.RefCount);
}
- [Test]
+ [Fact]
public void TestListChainsSimple()
{
- if (IsLinux)
- {
- Assert.AreEqual(0, IptcInterface.RefCount);
- using (IptcInterface iptc = new IptcInterface("filter", _ipVersion))
- {
+ _fixture.SkipIfNeeded();
- var chains = iptc.GetChains();
- Assert.AreNotEqual(0, chains.Count, "Expected atleast one chain");
- }
- Assert.AreEqual(0, IptcInterface.RefCount);
+ Assert.Equal(0, IptcInterface.RefCount);
+ using (var iptc = new IptcInterface("filter", _fixture.IpVersion))
+ {
+ var chains = iptc.GetChains();
+ Assert.True(chains.Count != 0, "Expected atleast one chain");
}
+ Assert.Equal(0, IptcInterface.RefCount);
}
- [Test]
+ [Fact]
public void TestListChainsMangle()
{
- if (IsLinux)
- {
- Assert.AreEqual(0, IptcInterface.RefCount);
- using (IptcInterface iptc = new IptcInterface("mangle", _ipVersion))
- {
+ _fixture.SkipIfNeeded();
- var chains = iptc.GetChains();
- Assert.AreNotEqual(0, chains.Count, "Expected atleast one chain");
-
- List expectedChains = new List
- {
- "PREROUTING",
- "INPUT",
- "FORWARD",
- "OUTPUT",
- "POSTROUTING"
- };
- CollectionAssert.AreEqual(expectedChains, iptc.GetChains(), "first table chain test");
+ Assert.Equal(0, IptcInterface.RefCount);
+ using (var iptc = new IptcInterface("mangle", _fixture.IpVersion))
+ {
+ var chains = iptc.GetChains();
+ Assert.True(chains.Count != 0, "Expected atleast one chain");
- //Test repeatable
- CollectionAssert.AreEqual(expectedChains, iptc.GetChains(), "second table chain test");
- }
- Assert.AreEqual(0, IptcInterface.RefCount);
+ List expectedChains = new List
+ {
+ "PREROUTING",
+ "INPUT",
+ "FORWARD",
+ "OUTPUT",
+ "POSTROUTING"
+ };
+
+ Assert.Equal(expectedChains, iptc.GetChains());
+ Assert.Equal(expectedChains, iptc.GetChains());
}
+ Assert.Equal(0, IptcInterface.RefCount);
}
}
}
diff --git a/IPTables.Net.Tests/LevensheteinSolutionTest.cs b/IPTables.Net.Tests/LevensheteinSolutionTest.cs
index 1b35172..639f5d1 100644
--- a/IPTables.Net.Tests/LevensheteinSolutionTest.cs
+++ b/IPTables.Net.Tests/LevensheteinSolutionTest.cs
@@ -3,13 +3,12 @@
using System.Linq;
using System.Text;
using IPTables.Net.Supporting;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- class LevensheteinSolutionTest
+ public class LevensheteinSolutionTest
{
- [TestCase(Ignore = "igonre")]
+ [Fact(Skip = "igonre")]
public void DistanceTest()
{
String s = "democrat";
@@ -18,10 +17,10 @@ public void DistanceTest()
LevenshteinSolution l = new LevenshteinSolution();
var distance = l.GetDistance(s.ToCharArray(), t.ToCharArray());
- Assert.AreEqual(8, distance);
+ Assert.Equal(8, distance);
}
- [TestCase(Ignore = "igonre")]
+ [Fact(Skip = "igonre")]
public void InstructionsTest()
{
String s = "democrat";
@@ -34,10 +33,10 @@ public void InstructionsTest()
string tApplied = new string(applied);
- Assert.AreEqual(t, tApplied);
+ Assert.Equal(t, tApplied);
}
- [TestCase(Ignore= "igonre")]
+ [Fact(Skip = "igonre")]
public void InstructionsBulkTest()
{
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
@@ -61,7 +60,7 @@ public void InstructionsBulkTest()
string tApplied = new string(applied);
- Assert.AreEqual(t, tApplied);
+ Assert.Equal(t, tApplied);
}
}
}
diff --git a/IPTables.Net.Tests/PortRangeHelpersTests.cs b/IPTables.Net.Tests/PortRangeHelpersTests.cs
index 0239e1a..458cd5b 100644
--- a/IPTables.Net.Tests/PortRangeHelpersTests.cs
+++ b/IPTables.Net.Tests/PortRangeHelpersTests.cs
@@ -4,14 +4,12 @@
using System.Text;
using IPTables.Net.Iptables.DataTypes;
using IPTables.Net.Iptables.Helpers;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
public class PortRangeHelpersTests
{
- [TestCase]
+ [Fact]
public void TestCompress1()
{
List input = new List { new PortOrRange(80) };
@@ -19,10 +17,10 @@ public void TestCompress1()
List actual = PortRangeHelpers.CompressRanges(input);
- CollectionAssert.AreEqual(output,actual);
+ Assert.Equal(output,actual);
}
- [TestCase]
+ [Fact]
public void TestCompress2()
{
List input = new List { new PortOrRange(80), new PortOrRange(82) };
@@ -30,10 +28,10 @@ public void TestCompress2()
List actual = PortRangeHelpers.CompressRanges(input);
- CollectionAssert.AreEqual(output, actual);
+ Assert.Equal(output, actual);
}
- [TestCase]
+ [Fact]
public void TestCompress3()
{
List input = new List { new PortOrRange(80), new PortOrRange(82, 84) };
@@ -41,10 +39,10 @@ public void TestCompress3()
List actual = PortRangeHelpers.CompressRanges(input);
- CollectionAssert.AreEqual(output, actual);
+ Assert.Equal(output, actual);
}
- [TestCase]
+ [Fact]
public void TestCompress4()
{
List input = new List { new PortOrRange(80), new PortOrRange(81, 84) };
@@ -52,10 +50,10 @@ public void TestCompress4()
List actual = PortRangeHelpers.CompressRanges(input);
- CollectionAssert.AreEqual(output, actual);
+ Assert.Equal(output, actual);
}
- [TestCase]
+ [Fact]
public void TestCompress5()
{
List input = new List { new PortOrRange(80), new PortOrRange(81) };
@@ -63,10 +61,10 @@ public void TestCompress5()
List actual = PortRangeHelpers.CompressRanges(input);
- CollectionAssert.AreEqual(output, actual);
+ Assert.Equal(output, actual);
}
- [TestCase]
+ [Fact]
public void TestCompress6()
{
List input = new List { new PortOrRange(80), new PortOrRange(81), new PortOrRange(82, 83), new PortOrRange(85), new PortOrRange(86,90) };
@@ -74,10 +72,10 @@ public void TestCompress6()
List actual = PortRangeHelpers.CompressRanges(input);
- CollectionAssert.AreEqual(output, actual);
+ Assert.Equal(output, actual);
}
- [TestCase]
+ [Fact]
public void TestCompress7()
{
List input = new List { new PortOrRange(80) };
@@ -85,10 +83,10 @@ public void TestCompress7()
List actual = PortRangeHelpers.CompressRanges(input);
- CollectionAssert.AreEqual(output, actual);
+ Assert.Equal(output, actual);
}
- [TestCase]
+ [Fact]
public void TestCompress8()
{
List input = new List { new PortOrRange(80, 90) };
@@ -96,26 +94,26 @@ public void TestCompress8()
List actual = PortRangeHelpers.CompressRanges(input);
- CollectionAssert.AreEqual(output, actual);
+ Assert.Equal(output, actual);
}
- [TestCase]
+ [Fact]
public void TestRangeCount1()
{
List input = new List { new PortOrRange(80), new PortOrRange(81), new PortOrRange(82, 83), new PortOrRange(85), new PortOrRange(86, 90) };
- Assert.AreEqual(1, PortRangeHelpers.CountRequiredMultiports(input));
+ Assert.Equal(1, PortRangeHelpers.CountRequiredMultiports(input));
}
- [TestCase]
+ [Fact]
public void TestRangeCount2()
{
List input = new List { new PortOrRange(80), new PortOrRange(81), new PortOrRange(82, 83), new PortOrRange(85), new PortOrRange(86, 90), new PortOrRange(180) };
- Assert.AreEqual(1, PortRangeHelpers.CountRequiredMultiports(input));
+ Assert.Equal(1, PortRangeHelpers.CountRequiredMultiports(input));
}
- [TestCase]
+ [Fact]
public void TestRangeCount3()
{
List input = new List { };
@@ -125,10 +123,10 @@ public void TestRangeCount3()
input.Add(new PortOrRange((uint)(100 + i)));
}
- Assert.AreEqual(1, PortRangeHelpers.CountRequiredMultiports(input));
+ Assert.Equal(1, PortRangeHelpers.CountRequiredMultiports(input));
}
- [TestCase]
+ [Fact]
public void TestRangeCount4()
{
List input = new List { };
@@ -138,10 +136,10 @@ public void TestRangeCount4()
input.Add(new PortOrRange((uint)(100 + i)));
}
- Assert.AreEqual(2, PortRangeHelpers.CountRequiredMultiports(input));
+ Assert.Equal(2, PortRangeHelpers.CountRequiredMultiports(input));
}
- [TestCase]
+ [Fact]
public void TestRangeCount5()
{
List input = new List { };
@@ -151,10 +149,10 @@ public void TestRangeCount5()
input.Add(new PortOrRange((uint)(100*i),(uint)((100*i) + 1)));
}
- Assert.AreEqual(2, PortRangeHelpers.CountRequiredMultiports(input));
+ Assert.Equal(2, PortRangeHelpers.CountRequiredMultiports(input));
}
- [TestCase]
+ [Fact]
public void TestRangeCount6()
{
List input = new List { };
@@ -164,7 +162,7 @@ public void TestRangeCount6()
input.Add(new PortOrRange((uint)(100 + i)));
}
- Assert.AreEqual(1, PortRangeHelpers.CountRequiredMultiports(input));
+ Assert.Equal(1, PortRangeHelpers.CountRequiredMultiports(input));
}
}
}
diff --git a/IPTables.Net.Tests/RuleBuilderMultiportTests.cs b/IPTables.Net.Tests/RuleBuilderMultiportTests.cs
index e3c6102..a3a2278 100644
--- a/IPTables.Net.Tests/RuleBuilderMultiportTests.cs
+++ b/IPTables.Net.Tests/RuleBuilderMultiportTests.cs
@@ -9,14 +9,12 @@
using IPTables.Net.Iptables.RuleGenerator;
using IPTables.Net.TestFramework;
using IPTables.Net.TestFramework.IpTablesRestore;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class RuleBuilderMultiportTests
+ public class RuleBuilderMultiportTests
{
- [Test]
+ [Fact]
public void TestSingular()
{
var mock = new MockIptablesSystemFactory();
@@ -32,13 +30,13 @@ public void TestSingular()
IpTablesRuleSet rules = new IpTablesRuleSet(4,system);
ma.Output(system, rules);
- Assert.AreEqual(1, rules.Chains.Count());
- Assert.AreEqual(2, rules.Chains.First().Rules.Count);
- Assert.AreEqual("-A INPUT -s 8.1.1.1 -j ACCEPT -m comment --comment '_|uXTlO5H/5x9hJe9WK1hw|1' -m multiport --sports 1:2", rules.Chains.First().Rules.First().GetActionCommand());
- Assert.AreEqual("-A INPUT -s 8.1.1.2 -j ACCEPT -m comment --comment '_|s5FXv5bN+84QgKZzjZ3Q|1' -m multiport --sports 3", rules.Chains.First().Rules.Skip(1).First().GetActionCommand());
+ Assert.Equal(1, rules.Chains.Count());
+ Assert.Equal(2, rules.Chains.First().Rules.Count);
+ Assert.Equal("-A INPUT -s 8.1.1.1 -j ACCEPT -m comment --comment '_|uXTlO5H/5x9hJe9WK1hw|1' -m multiport --sports 1:2", rules.Chains.First().Rules.First().GetActionCommand());
+ Assert.Equal("-A INPUT -s 8.1.1.2 -j ACCEPT -m comment --comment '_|s5FXv5bN+84QgKZzjZ3Q|1' -m multiport --sports 3", rules.Chains.First().Rules.Skip(1).First().GetActionCommand());
}
- [Test]
+ [Fact]
public void TestMultiple()
{
var mock = new MockIptablesSystemFactory();
@@ -70,12 +68,12 @@ public void TestMultiple()
IpTablesRuleSet rules = new IpTablesRuleSet(4,system);
ma.Output(system, rules);
- Assert.AreEqual(2, rules.Chains.Count());
- Assert.AreEqual(1, rules.Chains.GetChainOrDefault("INPUT","filter").Rules.Count);
- Assert.AreEqual("-A INPUT -s 8.1.1.1 -j uXTlO5H/5x9hJe9WK1hw -m comment --comment '_|MA|INPUT_8.1.1.1'",
+ Assert.Equal(2, rules.Chains.Count());
+ Assert.Equal(1, rules.Chains.GetChainOrDefault("INPUT","filter").Rules.Count);
+ Assert.Equal("-A INPUT -s 8.1.1.1 -j uXTlO5H/5x9hJe9WK1hw -m comment --comment '_|MA|INPUT_8.1.1.1'",
rules.Chains.GetChainOrDefault("INPUT", "filter").Rules.First().GetActionCommand());
- Assert.AreEqual("-A uXTlO5H/5x9hJe9WK1hw -j ACCEPT -m comment --comment '_|uXTlO5H/5x9hJe9WK1hw|1' -m multiport --sports 10,20,30,40,50,60,70,80,90,100,110,120,130,140,150",
+ Assert.Equal("-A uXTlO5H/5x9hJe9WK1hw -j ACCEPT -m comment --comment '_|uXTlO5H/5x9hJe9WK1hw|1' -m multiport --sports 10,20,30,40,50,60,70,80,90,100,110,120,130,140,150",
rules.Chains.GetChainOrDefault("uXTlO5H/5x9hJe9WK1hw", "filter").Rules.First().GetActionCommand());
}
diff --git a/IPTables.Net.Tests/RuleBuilderNestedTests.cs b/IPTables.Net.Tests/RuleBuilderNestedTests.cs
index 6186419..d5c5062 100644
--- a/IPTables.Net.Tests/RuleBuilderNestedTests.cs
+++ b/IPTables.Net.Tests/RuleBuilderNestedTests.cs
@@ -9,14 +9,12 @@
using IPTables.Net.Iptables.RuleGenerator;
using IPTables.Net.TestFramework;
using IPTables.Net.TestFramework.IpTablesRestore;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class RuleBuilderNestedTests
+ public class RuleBuilderNestedTests
{
- [Test]
+ [Fact]
public void TestNesting()
{
var mock = new MockIptablesSystemFactory();
@@ -31,9 +29,9 @@ public void TestNesting()
IpTablesRuleSet rules = new IpTablesRuleSet(4,system);
ma.Output(system, rules);
- Assert.AreEqual(3, rules.Chains.Count());
- Assert.AreEqual(2, rules.Chains.Skip(1).First().Rules.Count);
- Assert.AreEqual(1, rules.Chains.Skip(2).First().Rules.Count);
+ Assert.Equal(3, rules.Chains.Count());
+ Assert.Equal(2, rules.Chains.Skip(1).First().Rules.Count);
+ Assert.Equal(1, rules.Chains.Skip(2).First().Rules.Count);
}
private MultiportAggregator nestedGenerator(string arg1, string arg2)
diff --git a/IPTables.Net.Tests/RuleBuilderSplitterTests.cs b/IPTables.Net.Tests/RuleBuilderSplitterTests.cs
index cef3a3c..fdf118c 100644
--- a/IPTables.Net.Tests/RuleBuilderSplitterTests.cs
+++ b/IPTables.Net.Tests/RuleBuilderSplitterTests.cs
@@ -9,14 +9,12 @@
using IPTables.Net.Iptables.RuleGenerator;
using IPTables.Net.TestFramework;
using IPTables.Net.TestFramework.IpTablesRestore;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- class RuleBuilderSplitterTests
+ public class RuleBuilderSplitterTests
{
- [Test]
+ [Fact]
public void TestSplit()
{
var mock = new MockIptablesSystemFactory();
@@ -31,15 +29,15 @@ public void TestSplit()
IpTablesRuleSet rules = new IpTablesRuleSet(4,system);
ma.Output(system, rules);
- Assert.AreEqual(3, rules.Chains.Count());
- Assert.AreEqual(2, rules.Chains.First().Rules.Count);
- Assert.AreEqual(2, rules.Chains.Skip(1).First().Rules.Count);
- Assert.AreEqual(1, rules.Chains.Skip(2).First().Rules.Count);
- Assert.AreEqual("-A INPUT -s 8.1.1.1 -j QGkTSfSaLIaS4B/kr3WQ -m comment --comment '_|FS|INPUT_8.1.1.1'",
+ Assert.Equal(3, rules.Chains.Count());
+ Assert.Equal(2, rules.Chains.First().Rules.Count);
+ Assert.Equal(2, rules.Chains.Skip(1).First().Rules.Count);
+ Assert.Equal(1, rules.Chains.Skip(2).First().Rules.Count);
+ Assert.Equal("-A INPUT -s 8.1.1.1 -j QGkTSfSaLIaS4B/kr3WQ -m comment --comment '_|FS|INPUT_8.1.1.1'",
rules.Chains.First().Rules.First().GetActionCommand());
- Assert.AreEqual("-A INPUT -s 8.1.1.2 -j ciE0aMcfwN36u0sNiC6w -m comment --comment '_|FS|INPUT_8.1.1.2'",
+ Assert.Equal("-A INPUT -s 8.1.1.2 -j ciE0aMcfwN36u0sNiC6w -m comment --comment '_|FS|INPUT_8.1.1.2'",
rules.Chains.First().Rules.Skip(1).First().GetActionCommand());
- Assert.AreEqual("-A QGkTSfSaLIaS4B/kr3WQ -j ACCEPT -m udp --sport 1",
+ Assert.Equal("-A QGkTSfSaLIaS4B/kr3WQ -j ACCEPT -m udp --sport 1",
rules.Chains.Skip(1).First().Rules.First().GetActionCommand());
}
diff --git a/IPTables.Net.Tests/SingleCommentRuleParseTests.cs b/IPTables.Net.Tests/SingleCommentRuleParseTests.cs
index c8aacad..31a5523 100644
--- a/IPTables.Net.Tests/SingleCommentRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleCommentRuleParseTests.cs
@@ -1,14 +1,12 @@
using System;
using IPTables.Net.Iptables;
using IPTables.Net.Iptables.Modules.Comment;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleCommentRuleParseTests
+ public class SingleCommentRuleParseTests
{
- [Test]
+ [Fact]
public void TestDropFragmentedTcpDnsWithComment()
{
String rule = "-A INPUT -p tcp ! -f -j DROP -m tcp --sport 53 -m comment --comment 'this is a test rule'";
@@ -16,10 +14,10 @@ public void TestDropFragmentedTcpDnsWithComment()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestDropFragmentedTcpDnsWithCommentEquality()
{
String rule = "-A INPUT -p tcp ! -f -j DROP -m tcp --sport 53 -m comment --comment 'this is a test rule'";
@@ -28,11 +26,11 @@ public void TestDropFragmentedTcpDnsWithCommentEquality()
IpTablesRule irule1 = IpTablesRule.Parse(rule, null, chains, 4);
IpTablesRule irule2 = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.IsTrue(irule2.Compare(irule1));
+ Assert.True(irule2.Compare(irule1));
}
- [Test]
+ [Fact]
public void TestBlankComment ()
{
String rule = "-A INPUT -p tcp ! -f -j DROP -m comment --comment '' -m tcp --dport 53";
@@ -41,10 +39,10 @@ public void TestBlankComment ()
IpTablesRule irule1 = IpTablesRule.Parse(rule, null, chains, 4);
IpTablesRule irule2 = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.IsTrue(irule2.Compare(irule1));
+ Assert.True(irule2.Compare(irule1));
}
- [Test]
+ [Fact]
public void TestAddCommentAfter()
{
String rule1 = "-A INPUT -p tcp ! -f -j DROP -m tcp --sport 53";
@@ -54,7 +52,7 @@ public void TestAddCommentAfter()
IpTablesRule irule1 = IpTablesRule.Parse(rule1, null, chains);
irule1.SetComment("this is a test rule");
- Assert.AreEqual(rule2, irule1.GetActionCommand());
+ Assert.Equal(rule2, irule1.GetActionCommand());
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleConnlimitRuleParseTests.cs b/IPTables.Net.Tests/SingleConnlimitRuleParseTests.cs
index 6c4323e..a54d76a 100644
--- a/IPTables.Net.Tests/SingleConnlimitRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleConnlimitRuleParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleConnlimitRuleParseTests
+ public class SingleConnlimitRuleParseTests
{
- [Test]
+ [Fact]
public void TestDropConnectionLimit()
{
String rule = "-A INPUT -p tcp -j DROP -m connlimit --connlimit-above 10";
@@ -15,10 +13,10 @@ public void TestDropConnectionLimit()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestDropConnectionLimitEquality()
{
String rule = "-A INPUT -p tcp -j DROP -m connlimit --connlimit-above 10";
@@ -27,7 +25,7 @@ public void TestDropConnectionLimitEquality()
IpTablesRule irule1 = IpTablesRule.Parse(rule, null, chains, 4);
IpTablesRule irule2 = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.IsTrue(irule2.Compare(irule1));
+ Assert.True(irule2.Compare(irule1));
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleConnmarkRuleParseTests.cs b/IPTables.Net.Tests/SingleConnmarkRuleParseTests.cs
index d8d6824..7c72fb1 100644
--- a/IPTables.Net.Tests/SingleConnmarkRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleConnmarkRuleParseTests.cs
@@ -1,14 +1,12 @@
using System;
using IPTables.Net.Iptables;
using IPTables.Net.Iptables.Modules.Connmark;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleConnmarkRuleParseTests
+ public class SingleConnmarkRuleParseTests
{
- [Test]
+ [Fact]
public void TestXmark()
{
String rule = "-A INPUT -p tcp -j CONNMARK --set-xmark 0xFF";
@@ -17,11 +15,11 @@ public void TestXmark()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(ruleExpect, irule.GetActionCommand());
+ Assert.Equal(ruleExpect, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestMatchMark1()
{
String rule = "-A INPUT -p tcp -m connmark --mark 0xFF";
@@ -30,9 +28,9 @@ public void TestMatchMark1()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(ruleExpect, irule.GetActionCommand());
+ Assert.Equal(ruleExpect, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestMatchMark2()
{
String rule = "-A INPUT -p tcp -m connmark --mark 255";
@@ -41,9 +39,9 @@ public void TestMatchMark2()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(ruleExpect, irule.GetActionCommand());
+ Assert.Equal(ruleExpect, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestMatchMark3()
{
String rule = "-A INPUT -p tcp -m connmark --mark 255/0xFF";
@@ -53,11 +51,11 @@ public void TestMatchMark3()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
IpTablesRule irule2 = IpTablesRule.Parse(ruleExpect, null, chains, 4);
- Assert.AreEqual(ruleExpect, irule.GetActionCommand());
- Assert.IsTrue(irule.Compare(irule2));
+ Assert.Equal(ruleExpect, irule.GetActionCommand());
+ Assert.True(irule.Compare(irule2));
}
- [Test]
+ [Fact]
public void TestAndMark()
{
Int32 mark = 0;
@@ -67,10 +65,10 @@ public void TestAndMark()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(ruleExpect, irule.GetActionCommand());
+ Assert.Equal(ruleExpect, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestSetMark1()
{
String rule = "-A INPUT -j CONNMARK --set-xmark 0x200/0x1ffff00";
@@ -79,11 +77,11 @@ public void TestSetMark1()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(ruleExpect, irule.GetActionCommand());
- Assert.IsTrue(IpTablesRule.Parse(ruleExpect, null, chains, 4).Compare(irule));
+ Assert.Equal(ruleExpect, irule.GetActionCommand());
+ Assert.True(IpTablesRule.Parse(ruleExpect, null, chains, 4).Compare(irule));
}
- [Test]
+ [Fact]
public void TestSetMark2()
{
String rule = "-A INPUT -j CONNMARK --set-xmark "+0x200+"/0x1ffff00";
@@ -92,11 +90,11 @@ public void TestSetMark2()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(ruleExpect, irule.GetActionCommand());
- Assert.IsTrue(IpTablesRule.Parse(ruleExpect, null, chains, 4).Compare(irule));
+ Assert.Equal(ruleExpect, irule.GetActionCommand());
+ Assert.True(IpTablesRule.Parse(ruleExpect, null, chains, 4).Compare(irule));
}
- [Test]
+ [Fact]
public void TestSetMark3()
{
String rule = "-A INPUT -j CONNMARK --set-xmark " + 0x200 + "/0x1ffff00";
@@ -105,10 +103,10 @@ public void TestSetMark3()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.IsTrue(IpTablesRule.Parse(ruleExpect, null, chains, 4).Compare(irule));
+ Assert.True(IpTablesRule.Parse(ruleExpect, null, chains, 4).Compare(irule));
}
- [Test]
+ [Fact]
public void TestOrMark()
{
Int32 mark = 0;
@@ -118,10 +116,10 @@ public void TestOrMark()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(ruleExpect, irule.GetActionCommand());
+ Assert.Equal(ruleExpect, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestXorMark()
{
Int32 mark = 0;
@@ -131,10 +129,10 @@ public void TestXorMark()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(ruleExpect, irule.GetActionCommand());
+ Assert.Equal(ruleExpect, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestXMarkMasked()
{
String rule = "-A RETURN_AFWCON -j CONNMARK --set-xmark 0x1/0x1";
@@ -142,11 +140,11 @@ public void TestXMarkMasked()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestRestoreMark()
{
String rule = "-A PREROUTING -j CONNMARK --restore-mark --ctmask 0x11 --nfmask 0x3FFFF00";
@@ -154,7 +152,7 @@ public void TestRestoreMark()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleConntrackRuleParseTests.cs b/IPTables.Net.Tests/SingleConntrackRuleParseTests.cs
index 751c867..cd6a5ad 100644
--- a/IPTables.Net.Tests/SingleConntrackRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleConntrackRuleParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleConntrackRuleParseTests
+ public class SingleConntrackRuleParseTests
{
- [Test]
+ [Fact]
public void TestParse()
{
String rule1 = "-A PREROUTING -t raw -p tcp -j CT --ctevents new,destroy";
@@ -18,7 +16,7 @@ public void TestParse()
IpTablesRule irule2 = IpTablesRule.Parse(rule2, null, chains, 4);
irule2.Equals(irule1);
- Assert.IsTrue(irule2.Compare(irule1));
+ Assert.True(irule2.Compare(irule1));
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleCoreRuleParseTests.cs b/IPTables.Net.Tests/SingleCoreRuleParseTests.cs
index e61e14b..94a973c 100644
--- a/IPTables.Net.Tests/SingleCoreRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleCoreRuleParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleCoreRuleParseTests
+ public class SingleCoreRuleParseTests
{
- [Test]
+ [Fact]
public void TestCoreDropingDestination()
{
String rule = "-A INPUT -d 1.2.3.4/16 -j DROP";
@@ -15,10 +13,10 @@ public void TestCoreDropingDestination()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestCoreDropingInterface()
{
String rule = "-A INPUT -i eth0 -j DROP";
@@ -26,10 +24,10 @@ public void TestCoreDropingInterface()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestCoreDropingSource()
{
String rule = "-A INPUT -s 1.2.3.4 -j DROP";
@@ -37,10 +35,10 @@ public void TestCoreDropingSource()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestParsingWithMultipleSpaces()
{
String rule = "-A INPUT -s 1.2.3.4 -j DROP";
@@ -49,7 +47,7 @@ public void TestParsingWithMultipleSpaces()
IpTablesRule.Parse(rule, null, chains, 4);
}
- [Test]
+ [Fact]
public void TestParsingWithSpaceAtEnd()
{
String rule = "-A INPUT -s 1.2.3.4 -j DROP ";
@@ -58,7 +56,7 @@ public void TestParsingWithSpaceAtEnd()
IpTablesRule.Parse(rule, null, chains, 4);
}
- [Test]
+ [Fact]
public void TestParsingWithSpaceAtStart()
{
String rule = " -A INPUT -s 1.2.3.4 -j DROP";
@@ -66,7 +64,7 @@ public void TestParsingWithSpaceAtStart()
IpTablesRule.Parse(rule, null, chains, 4);
}
- [Test]
+ [Fact]
public void TestParsingWithSpacesAtStart()
{
String rule = " -A INPUT -s 1.2.3.4 -j DROP";
@@ -75,7 +73,7 @@ public void TestParsingWithSpacesAtStart()
IpTablesRule.Parse(rule, null, chains, 4);
}
- [Test]
+ [Fact]
public void TestCoreDropingUdp()
{
String rule = "-A INPUT -p udp -j DROP";
@@ -83,10 +81,10 @@ public void TestCoreDropingUdp()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestCoreFragmenting()
{
String rule = "-A INPUT ! -f -j test";
@@ -94,10 +92,10 @@ public void TestCoreFragmenting()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestCoreDropingDestinationEquality()
{
String rule = "-A INPUT -d 1.2.3.4/16 -j DROP";
@@ -106,10 +104,10 @@ public void TestCoreDropingDestinationEquality()
IpTablesRule irule1 = IpTablesRule.Parse(rule, null, chains, 4);
IpTablesRule irule2 = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.IsTrue(irule2.Compare(irule1));
+ Assert.True(irule2.Compare(irule1));
}
- [Test]
+ [Fact]
public void TestCoreDropingInterfaceEquality()
{
String rule = "-A INPUT -i eth0 -j DROP";
@@ -118,10 +116,10 @@ public void TestCoreDropingInterfaceEquality()
IpTablesRule irule1 = IpTablesRule.Parse(rule, null, chains, 4);
IpTablesRule irule2 = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.IsTrue(irule2.Compare(irule1));
+ Assert.True(irule2.Compare(irule1));
}
- [Test]
+ [Fact]
public void TestCoreDropingSourceEquality()
{
String rule = "-A INPUT -s 1.2.3.4 -j DROP";
@@ -130,10 +128,10 @@ public void TestCoreDropingSourceEquality()
IpTablesRule irule1 = IpTablesRule.Parse(rule, null, chains, 4);
IpTablesRule irule2 = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.IsTrue(irule2.Compare(irule1));
+ Assert.True(irule2.Compare(irule1));
}
- [Test]
+ [Fact]
public void TestCoreDropingUdpEquality()
{
String rule = "-A INPUT -p udp -j DROP";
@@ -142,10 +140,10 @@ public void TestCoreDropingUdpEquality()
IpTablesRule irule1 = IpTablesRule.Parse(rule, null, chains, 4);
IpTablesRule irule2 = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.IsTrue(irule2.Compare(irule1));
+ Assert.True(irule2.Compare(irule1));
}
- [Test]
+ [Fact]
public void TestCoreFragmentingEquality()
{
String rule = "-A INPUT ! -f -j test";
@@ -154,7 +152,7 @@ public void TestCoreFragmentingEquality()
IpTablesRule irule1 = IpTablesRule.Parse(rule, null, chains, 4);
IpTablesRule irule2 = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.IsTrue(irule2.Compare(irule1));
+ Assert.True(irule2.Compare(irule1));
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleDnatParseTests.cs b/IPTables.Net.Tests/SingleDnatParseTests.cs
index 03af8de..3dee874 100644
--- a/IPTables.Net.Tests/SingleDnatParseTests.cs
+++ b/IPTables.Net.Tests/SingleDnatParseTests.cs
@@ -1,14 +1,12 @@
using System;
using IPTables.Net.Iptables;
using IPTables.Net.Iptables.Modules.Comment;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleDnatParseTests
+ public class SingleDnatParseTests
{
- [Test]
+ [Fact]
public void DnatTest1()
{
String rule = "-A A+B -p tcp -j DNAT --to-destination 1.2.3.4";
@@ -16,8 +14,8 @@ public void DnatTest1()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
- Assert.IsTrue(irule.Compare(IpTablesRule.Parse(rule, null, chains, 4)));
+ Assert.Equal(rule, irule.GetActionCommand());
+ Assert.True(irule.Compare(IpTablesRule.Parse(rule, null, chains, 4)));
}
}
diff --git a/IPTables.Net.Tests/SingleDnatRuleParseTests.cs b/IPTables.Net.Tests/SingleDnatRuleParseTests.cs
index 4d7e009..ad99a59 100644
--- a/IPTables.Net.Tests/SingleDnatRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleDnatRuleParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleDnatRuleParseTests
+ public class SingleDnatRuleParseTests
{
- [Test]
+ [Fact]
public void TestDnatSingleSource()
{
String rule = "-A PREROUTING -t nat -d 1.1.1.1/24 -j DNAT --to-destination 2.2.2.2";
@@ -15,10 +13,10 @@ public void TestDnatSingleSource()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestDnatRangeSourceAndEquality()
{
String rule = "-A POSTROUTING -t nat -d 1.1.1.1/24 -j DNAT --to-destination 2.2.2.1-2.2.2.250";
@@ -27,9 +25,9 @@ public void TestDnatRangeSourceAndEquality()
IpTablesRule irule1 = IpTablesRule.Parse(rule, null, chains, 4);
IpTablesRule irule2 = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.IsTrue(irule2.Compare(irule1));
- Assert.AreEqual(rule, irule1.GetActionCommand());
- Assert.AreEqual(rule, irule2.GetActionCommand());
+ Assert.True(irule2.Compare(irule1));
+ Assert.Equal(rule, irule1.GetActionCommand());
+ Assert.Equal(rule, irule2.GetActionCommand());
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleHashlimitRuleParseTests.cs b/IPTables.Net.Tests/SingleHashlimitRuleParseTests.cs
index d821355..aacbaf6 100644
--- a/IPTables.Net.Tests/SingleHashlimitRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleHashlimitRuleParseTests.cs
@@ -1,73 +1,71 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleHashlimitRuleParseTests
+ public class SingleHashlimitRuleParseTests
{
- [Test]
+ [Fact]
public void TestCompare1()
{
String rule = "-A ABC -m hashlimit --hashlimit-name aaaaaaaaaaaaaaaaaaaaaa --hashlimit-above 125/second --hashlimit-burst 500 --hashlimit-mode dstip,dstport --hashlimit-srcmask 32 --hashlimit-dstmask 32 --hashlimit-htable-size 65000 --hashlimit-htable-max 30000 --hashlimit-htable-expire 6 --hashlimit-htable-gcinterval 600 -j AVS";
IpTablesChainSet chains = new IpTablesChainSet(4);
- Assert.IsTrue(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule, null, chains, 4)));
+ Assert.True(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule, null, chains, 4)));
}
- [Test]
+ [Fact]
public void TestCompare2()
{
String rule = "-A AAAA -t raw -m hashlimit --hashlimit-name synflood_spoofe --hashlimit-above 111/second --hashlimit-burst 500 --hashlimit-mode dstip,dstport --hashlimit-srcmask 32 --hashlimit-dstmask 32 --hashlimit-htable-size 65000 --hashlimit-htable-max 30000 --hashlimit-htable-expire 6 --hashlimit-htable-gcinterval 600 -g AA";
String rule2 = "-A AAAA -t raw -m hashlimit --hashlimit-above 111/sec --hashlimit-burst 500 --hashlimit-mode dstip,dstport --hashlimit-name synflood_spoofe --hashlimit-htable-size 65000 --hashlimit-htable-max 30000 --hashlimit-htable-gcinterval 600 --hashlimit-htable-expire 6 -g AA";
IpTablesChainSet chains = new IpTablesChainSet(4);
- Assert.IsTrue(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule2, null, chains)));
+ Assert.True(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule2, null, chains)));
}
- [Test]
+ [Fact]
public void TestCompare3()
{
String rule = "-A AAAA -t raw -m hashlimit --hashlimit-name X$a|b|c --hashlimit-above 111/second --hashlimit-burst 500 --hashlimit-mode dstport --hashlimit-srcmask 32 --hashlimit-dstmask 32 --hashlimit-htable-size 65000 --hashlimit-htable-max 30000 --hashlimit-htable-expire 6 --hashlimit-htable-gcinterval 600 -g AA";
String rule2 = "-A AAAA -t raw -m hashlimit --hashlimit-above 111/sec --hashlimit-burst 500 --hashlimit-mode dstport --hashlimit-name 'X$a|b|c' --hashlimit-htable-size 65000 --hashlimit-htable-max 30000 --hashlimit-htable-gcinterval 600 --hashlimit-htable-expire 6 -g AA";
IpTablesChainSet chains = new IpTablesChainSet(4);
- Assert.IsTrue(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule2, null, chains)));
+ Assert.True(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule2, null, chains)));
}
- [Test]
+ [Fact]
public void TestCompare4()
{
String rule = "-A AAA -p udp -m hashlimit --hashlimit-upto 5000/sec --hashlimit-burst 10000 --hashlimit-mode dstport --hashlimit-name X|gm2nkFUEm3KMQelhNE9A --hashlimit-htable-size 32782 --hashlimit-htable-max 200000 --hashlimit-htable-expire 10000 -m comment --comment \"X|A|B\" -g aaaa";
String rule2 = "-A AAA -p udp -g N_RE_gm2nkFUEm3KMQelhNE9A -m hashlimit --hashlimit-name 'X|gm2nkFUEm3KMQelhNE9A' --hashlimit-upto 5000/second --hashlimit-burst 10000 --hashlimit-mode dstport --hashlimit-srcmask 32 --hashlimit-dstmask 32 --hashlimit-htable-size 32782 --hashlimit-htable-max 200000 --hashlimit-htable-expire 10000 --hashlimit-htable-gcinterval 1000 -m comment --comment 'X|A|B' -g aaaa";
IpTablesChainSet chains = new IpTablesChainSet(4);
- Assert.IsTrue(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule2, null, chains)));
+ Assert.True(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule2, null, chains)));
}
- [Test]
+ [Fact]
public void TestByte1()
{
String rule = "-A ABC -m hashlimit --hashlimit-name aaaaaaaaaaaaaaaaaaaaaa --hashlimit-above 5kb/second --hashlimit-burst 500 --hashlimit-mode dstip,dstport --hashlimit-srcmask 32 --hashlimit-dstmask 32 --hashlimit-htable-size 65000 --hashlimit-htable-max 30000 --hashlimit-htable-expire 6 --hashlimit-htable-gcinterval 600 -j AVS";
IpTablesChainSet chains = new IpTablesChainSet(4);
- Assert.IsTrue(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule, null, chains, 4)));
+ Assert.True(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule, null, chains, 4)));
String outputRule = IpTablesRule.Parse(rule, null, chains, 4).GetActionCommand();
- Assert.IsTrue(outputRule.Contains("5kb/s"));
+ Assert.True(outputRule.Contains("5kb/s"));
}
- [Test]
+ [Fact]
public void TestByte2()
{
String rule = "-A ABC -m hashlimit --hashlimit-name aaaaaaaaaaaaaaaaaaaaaa --hashlimit-above 5kb/second --hashlimit-burst 1mb --hashlimit-mode dstip,dstport --hashlimit-srcmask 32 --hashlimit-dstmask 32 --hashlimit-htable-size 65000 --hashlimit-htable-max 30000 --hashlimit-htable-expire 6 --hashlimit-htable-gcinterval 600 -j AVS";
IpTablesChainSet chains = new IpTablesChainSet(4);
- Assert.IsTrue(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule, null, chains, 4)));
- Assert.IsTrue(IpTablesRule.Parse(rule, null, chains, 4).GetActionCommand().Contains("5kb/s"));
+ Assert.True(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule, null, chains, 4)));
+ Assert.True(IpTablesRule.Parse(rule, null, chains, 4).GetActionCommand().Contains("5kb/s"));
}
- [Test]
+ [Fact]
public void TestByte3()
{
String rule1 = "-A ABC -m hashlimit --hashlimit-above 16b/s --hashlimit-burst 32b --hashlimit-mode srcip,dstip --hashlimit-name C_82 --hashlimit-htable-size 16000 --hashlimit-htable-max 256000 --hashlimit-htable-expire 10000";
@@ -76,7 +74,7 @@ public void TestByte3()
var r1 = IpTablesRule.Parse(rule1, null, chains, 4);
}
- [Test]
+ [Fact]
public void TestByte4()
{
String rule2 = "-A ABC -m hashlimit --hashlimit-name C_82 --hashlimit-above 10kb/second --hashlimit-burst 10kb --hashlimit-mode srcip,dstip --hashlimit-srcmask 32 --hashlimit-dstmask 32 --hashlimit-htable-size 16000 --hashlimit-htable-max 256000 --hashlimit-htable-expire 10000 --hashlimit-htable-gcinterval 1000";
@@ -85,11 +83,11 @@ public void TestByte4()
var r1 = IpTablesRule.Parse(rule, null, chains, 4);
var r2 = IpTablesRule.Parse(rule2, null, chains, 4);
- Assert.IsTrue(r1.Compare(r2));
- Assert.IsTrue(r1.GetActionCommand().Contains(" 10kb"), r1.GetActionCommand());
+ Assert.True(r1.Compare(r2));
+ Assert.True(r1.GetActionCommand().Contains(" 10kb"), r1.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestByte5()
{
String rule = "-A ABC -m hashlimit --hashlimit-name C_82 --hashlimit-above 100b/second --hashlimit-burst 200b --hashlimit-mode srcip,dstip --hashlimit-srcmask 32 --hashlimit-dstmask 32 --hashlimit-htable-size 16000 --hashlimit-htable-max 256000 --hashlimit-htable-expire 10000 --hashlimit-htable-gcinterval 1000";
@@ -97,12 +95,12 @@ public void TestByte5()
var r1 = IpTablesRule.Parse(rule, null, chains, 4);
var outputRule = r1.GetActionCommand();
- Assert.IsTrue(outputRule.Contains(" 96b/s"), r1.GetActionCommand());
- Assert.IsTrue(outputRule.Contains(" 192b "), r1.GetActionCommand());
+ Assert.True(outputRule.Contains(" 96b/s"), r1.GetActionCommand());
+ Assert.True(outputRule.Contains(" 192b "), r1.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestRateCompare()
{
String rule = "-A ABC -m hashlimit --hashlimit-name C_82 --hashlimit-above 500/s --hashlimit-mode srcip,dstip --hashlimit-srcmask 32 --hashlimit-dstmask 32 --hashlimit-htable-size 16000 --hashlimit-htable-max 256000 --hashlimit-htable-expire 10000 --hashlimit-htable-gcinterval 1000";
@@ -112,7 +110,7 @@ public void TestRateCompare()
var r1 = IpTablesRule.Parse(rule, null, chains, 4);
var r2 = IpTablesRule.Parse(rule2, null, chains, 4);
- Assert.IsFalse(r1.Compare(r2));
+ Assert.False(r1.Compare(r2));
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleHelperRuleParseTests.cs b/IPTables.Net.Tests/SingleHelperRuleParseTests.cs
index 8338921..d31f7af 100644
--- a/IPTables.Net.Tests/SingleHelperRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleHelperRuleParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleHelperRuleParseTests
+ public class SingleHelperRuleParseTests
{
- [Test]
+ [Fact]
public void TestNotHelper()
{
String rule = "-A INPUT -m helper ! --helper cba -j ACCEPT";
@@ -15,10 +13,10 @@ public void TestNotHelper()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestHelper()
{
String rule = "-A INPUT -m helper ! --helper abc -j ACCEPT";
@@ -26,7 +24,7 @@ public void TestHelper()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleIpSetRuleParseTests.cs b/IPTables.Net.Tests/SingleIpSetRuleParseTests.cs
index 3f670bf..70920d0 100644
--- a/IPTables.Net.Tests/SingleIpSetRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleIpSetRuleParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleIpSetRuleParseTests
+ public class SingleIpSetRuleParseTests
{
- [Test]
+ [Fact]
public void Test1()
{
String rule = "-A FORWARD -m set --match-set test src";
@@ -15,10 +13,10 @@ public void Test1()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void Test2()
{
String rule = "-A FORWARD -m set --match-set test src --return-nomatch ! --update-counters --packets-lt 3 ! --bytes-eq 1";
@@ -26,7 +24,7 @@ public void Test2()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleLengthRuleParseTests.cs b/IPTables.Net.Tests/SingleLengthRuleParseTests.cs
index 06466c2..d58e5d3 100644
--- a/IPTables.Net.Tests/SingleLengthRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleLengthRuleParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleLengthRuleParseTests
+ public class SingleLengthRuleParseTests
{
- [Test]
+ [Fact]
public void TestLengthRange()
{
String rule = "-A INPUT -m length --length 10:100 -j ACCEPT";
@@ -15,9 +13,9 @@ public void TestLengthRange()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestNotLengthRange()
{
String rule = "-A INPUT -m length ! --length 10:100 -j ACCEPT";
@@ -25,10 +23,10 @@ public void TestNotLengthRange()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestNotLength()
{
String rule = "-A INPUT -m length ! --length 10 -j ACCEPT";
@@ -36,7 +34,7 @@ public void TestNotLength()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleLimitParseTests.cs b/IPTables.Net.Tests/SingleLimitParseTests.cs
index c1a9ca1..fbd0cf1 100644
--- a/IPTables.Net.Tests/SingleLimitParseTests.cs
+++ b/IPTables.Net.Tests/SingleLimitParseTests.cs
@@ -1,14 +1,12 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleLimitRuleParseTests
+ public class SingleLimitRuleParseTests
{
- [Test]
+ [Fact]
public void TestRateCompare()
{
String rule = "-A ABC -m limit --limit 500/s";
@@ -18,9 +16,9 @@ public void TestRateCompare()
var r1 = IpTablesRule.Parse(rule, null, chains, 4);
var r2 = IpTablesRule.Parse(rule2, null, chains, 4);
- Assert.IsFalse(r1.Compare(r2));
+ Assert.False(r1.Compare(r2));
}
- [Test]
+ [Fact]
public void TestRateCompare2()
{
String rule = "-A ABC -m limit --limit 3333/s";
@@ -30,9 +28,9 @@ public void TestRateCompare2()
var r1 = IpTablesRule.Parse(rule, null, chains, 4);
var r2 = IpTablesRule.Parse(rule2, null, chains, 4);
- Assert.IsTrue(r1.Compare(r2));
+ Assert.True(r1.Compare(r2));
}
- [Test]
+ [Fact]
public void TestRateCompare3()
{
String rule = "-A ABC -m limit --limit 1500/s";
@@ -42,7 +40,7 @@ public void TestRateCompare3()
var r1 = IpTablesRule.Parse(rule, null, chains, 4);
var r2 = IpTablesRule.Parse(rule2, null, chains, 4);
- Assert.IsTrue(r1.Compare(r2));
+ Assert.True(r1.Compare(r2));
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleLogRuleParseTests.cs b/IPTables.Net.Tests/SingleLogRuleParseTests.cs
index 7389d94..1119fb3 100644
--- a/IPTables.Net.Tests/SingleLogRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleLogRuleParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleLogRuleParseTests
+ public class SingleLogRuleParseTests
{
- [Test]
+ [Fact]
public void TestLogWithPrefix()
{
String rule = "-A INPUT -j LOG --log-prefix 'IPTABLES (Rule ATTACKED): ' --log-level 7";
@@ -15,7 +13,7 @@ public void TestLogWithPrefix()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleMarkRuleParseTests.cs b/IPTables.Net.Tests/SingleMarkRuleParseTests.cs
index 2b91eda..7edb1c1 100644
--- a/IPTables.Net.Tests/SingleMarkRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleMarkRuleParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleMarkRuleParseTests
+ public class SingleMarkRuleParseTests
{
- [Test]
+ [Fact]
public void MatchMarkDec()
{
String rule = "-A INPUT -p tcp -j ACCEPT -m mark --mark 13041408/0xFFFF00";
@@ -16,11 +14,11 @@ public void MatchMarkDec()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(ruleExpect, irule.GetActionCommand());
- Assert.IsTrue(IpTablesRule.Parse(ruleExpect, null, chains, 4).Compare(irule));
+ Assert.Equal(ruleExpect, irule.GetActionCommand());
+ Assert.True(IpTablesRule.Parse(ruleExpect, null, chains, 4).Compare(irule));
}
- [Test]
+ [Fact]
public void MatchMarkHex()
{
String rule = "-A INPUT -p tcp -j ACCEPT -m mark --mark 0xc6ff00/0xFFFF00";
@@ -29,12 +27,12 @@ public void MatchMarkHex()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(ruleExpect, irule.GetActionCommand());
- Assert.IsTrue(IpTablesRule.Parse(ruleExpect, null, chains, 4).Compare(irule));
+ Assert.Equal(ruleExpect, irule.GetActionCommand());
+ Assert.True(IpTablesRule.Parse(ruleExpect, null, chains, 4).Compare(irule));
}
- [Test]
+ [Fact]
public void TestXmark()
{
String rule = "-A INPUT -p tcp -j MARK --set-xmark 0xFF";
@@ -43,10 +41,10 @@ public void TestXmark()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(ruleExpect, irule.GetActionCommand());
+ Assert.Equal(ruleExpect, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestAndMark()
{
Int32 mark = 0;
@@ -56,10 +54,10 @@ public void TestAndMark()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(ruleExpect, irule.GetActionCommand());
+ Assert.Equal(ruleExpect, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestOrMark()
{
Int32 mark = 0;
@@ -69,10 +67,10 @@ public void TestOrMark()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(ruleExpect, irule.GetActionCommand());
+ Assert.Equal(ruleExpect, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestXorMark()
{
Int32 mark = 0;
@@ -82,7 +80,7 @@ public void TestXorMark()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(ruleExpect, irule.GetActionCommand());
+ Assert.Equal(ruleExpect, irule.GetActionCommand());
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleMssRuleParseTests.cs b/IPTables.Net.Tests/SingleMssRuleParseTests.cs
index ee040a8..1551e79 100644
--- a/IPTables.Net.Tests/SingleMssRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleMssRuleParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleMssRuleParseTests
+ public class SingleMssRuleParseTests
{
- [Test]
+ [Fact]
public void TestMssRange()
{
String rule = "-A INPUT -m tcpmss --mss 10:100 -j ACCEPT";
@@ -15,9 +13,9 @@ public void TestMssRange()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestMssWithSetMssRange()
{
String rule = "-A INPUT -m tcpmss --mss 10:100 -j TCPMSS --set-mss 1000";
@@ -25,7 +23,7 @@ public void TestMssWithSetMssRange()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleMultiportRuleParseTests.cs b/IPTables.Net.Tests/SingleMultiportRuleParseTests.cs
index 7ad82de..3e240db 100644
--- a/IPTables.Net.Tests/SingleMultiportRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleMultiportRuleParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleMultiportRuleParseTests
+ public class SingleMultiportRuleParseTests
{
- [Test]
+ [Fact]
public void TestMultiports()
{
String rule = "-A INPUT -p tcp -m multiport --ports 80,1000:1080";
@@ -15,9 +13,9 @@ public void TestMultiports()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestDestinationMultiports()
{
String rule = "-A INPUT -p tcp -m multiport --sports 80,1000:1080";
@@ -25,9 +23,9 @@ public void TestDestinationMultiports()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestSourceMultiports()
{
String rule = "-A INPUT -p tcp -m multiport --dports 80,1000:1080";
@@ -35,10 +33,10 @@ public void TestSourceMultiports()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TesNottMultiports()
{
String rule = "-A INPUT -p tcp -m multiport ! --ports 80,1000:1080";
@@ -46,9 +44,9 @@ public void TesNottMultiports()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestDestinationNotMultiports()
{
String rule = "-A INPUT -p tcp -m multiport ! --sports 80,1000:1080";
@@ -56,9 +54,9 @@ public void TestDestinationNotMultiports()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestSourceNotMultiports()
{
String rule = "-A INPUT -p tcp -m multiport ! --dports 80,1000:1080";
@@ -66,7 +64,7 @@ public void TestSourceNotMultiports()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleNetflowRuleParseTests.cs b/IPTables.Net.Tests/SingleNetflowRuleParseTests.cs
index 83ca482..dd7c2ee 100644
--- a/IPTables.Net.Tests/SingleNetflowRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleNetflowRuleParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleNetflowRuleParseTests
+ public class SingleNetflowRuleParseTests
{
- [Test]
+ [Fact]
public void TestFwmark()
{
String rule = "-A INPUT -m netflow --fw_status 1 -j ACCEPT";
@@ -15,9 +13,9 @@ public void TestFwmark()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestFwmarkCt()
{
String rule = "-A INPUT -m ctnetflow --fw_status 1 -j ACCEPT";
@@ -25,11 +23,11 @@ public void TestFwmarkCt()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestNoPorts()
{
String rule = "-A INPUT -m netflow --fw_status 65 --nf-noports -j DROP";
@@ -37,7 +35,7 @@ public void TestNoPorts()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleNfacctRuleParseTests.cs b/IPTables.Net.Tests/SingleNfacctRuleParseTests.cs
index e389274..e29838f 100644
--- a/IPTables.Net.Tests/SingleNfacctRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleNfacctRuleParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleNfacctRuleParseTests
+ public class SingleNfacctRuleParseTests
{
- [Test]
+ [Fact]
public void TestSmall()
{
String rule = "-A INPUT -j ACCEPT -m nfacct --nfacct-name test";
@@ -15,10 +13,10 @@ public void TestSmall()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestQuote()
{
String rule = "-A INPUT -j ACCEPT -m nfacct --nfacct-name \"test\"";
@@ -27,11 +25,11 @@ public void TestQuote()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule2, irule.GetActionCommand());
- Assert.IsTrue(IpTablesRule.Parse(rule2, null, chains, 4).Compare(irule));
+ Assert.Equal(rule2, irule.GetActionCommand());
+ Assert.True(IpTablesRule.Parse(rule2, null, chains, 4).Compare(irule));
}
- [Test]
+ [Fact]
public void TestDoubleSpace()
{
String rule = "-A INPUT -j ACCEPT -m nfacct --nfacct-name \"test\"";
@@ -40,8 +38,8 @@ public void TestDoubleSpace()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule2, irule.GetActionCommand());
- Assert.IsTrue(IpTablesRule.Parse(rule2, null, chains, 4).Compare(irule));
+ Assert.Equal(rule2, irule.GetActionCommand());
+ Assert.True(IpTablesRule.Parse(rule2, null, chains, 4).Compare(irule));
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleNflogRuleParseTests.cs b/IPTables.Net.Tests/SingleNflogRuleParseTests.cs
index f2cf1f4..53b7326 100644
--- a/IPTables.Net.Tests/SingleNflogRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleNflogRuleParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleNflogRuleParseTests
+ public class SingleNflogRuleParseTests
{
- [Test]
+ [Fact]
public void TestXmark()
{
String rule = "-A INPUT -j NFLOG --nflog-group 30";
@@ -15,7 +13,7 @@ public void TestXmark()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleNqueueRuleParseTests.cs b/IPTables.Net.Tests/SingleNqueueRuleParseTests.cs
index eccf37f..515dc98 100644
--- a/IPTables.Net.Tests/SingleNqueueRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleNqueueRuleParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleNqueueRuleParseTests
+ public class SingleNqueueRuleParseTests
{
- [Test]
+ [Fact]
public void TestXmark()
{
String rule = "-A INPUT -j NFQUEUE --queue-num 1 --queue-bypass";
@@ -15,7 +13,7 @@ public void TestXmark()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SinglePolyfillTests.cs b/IPTables.Net.Tests/SinglePolyfillTests.cs
index 1055e76..f2a26b8 100644
--- a/IPTables.Net.Tests/SinglePolyfillTests.cs
+++ b/IPTables.Net.Tests/SinglePolyfillTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SinglePolyfillTests
+ public class SinglePolyfillTests
{
- [Test]
+ [Fact]
public void TestPolyfillParse()
{
String rule = "-A INPUT -m unknown --unknown";
@@ -15,11 +13,11 @@ public void TestPolyfillParse()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestPolyfillParseMultiple()
{
String rule = "-A INPUT -m unknown --unknown -m unknown2";
@@ -27,10 +25,10 @@ public void TestPolyfillParseMultiple()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestPolyfillParseAdditionalOptionsAfter()
{
String rule = "-A INPUT -m unknown --unknown -p tcp -d 1.1.1.1 -m tcp --dport 80";
@@ -38,29 +36,29 @@ public void TestPolyfillParseAdditionalOptionsAfter()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestPolyfillArgumentsComparison1()
{
String rule = "-A INPUT -m unknown --unknown --unknown-2 1111 -p tcp -d 1.1.1.1 -m tcp --dport 80";
IpTablesChainSet chains = new IpTablesChainSet(4);
- Assert.IsTrue(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule, null, chains, 4)));
+ Assert.True(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule, null, chains, 4)));
}
- [Test]
+ [Fact]
public void TestPolyfillArgumentsComparison2()
{
String rule =
"-A INPUT -m unknown --unknown --unknown-2 1111 -m unknown2 --unknown2 -p tcp -d 1.1.1.1 -m tcp --dport 80";
IpTablesChainSet chains = new IpTablesChainSet(4);
- Assert.IsTrue(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule, null, chains, 4)));
+ Assert.True(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule, null, chains, 4)));
}
- [Test]
+ [Fact]
public void TestPolyfillArgumentsComparison3()
{
String rule =
@@ -69,10 +67,10 @@ public void TestPolyfillArgumentsComparison3()
"-A INPUT -m unknown2 --unknown2 -m unknown --unknown --unknown-2 1111 -p tcp -d 1.1.1.1 -m tcp --dport 80";
IpTablesChainSet chains = new IpTablesChainSet(4);
- Assert.IsTrue(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule2, null, chains)));
+ Assert.True(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule2, null, chains)));
}
- [Test]
+ [Fact]
public void TestPolyfillArgumentsComparison4()
{
String rule =
@@ -81,15 +79,15 @@ public void TestPolyfillArgumentsComparison4()
"-A INPUT -m unknown2 --unknown2 -m unknown --unknown --unknown-2 \'this has spaces & a symbol\' -p tcp -d 1.1.1.1 -m tcp --dport 80";
IpTablesChainSet chains = new IpTablesChainSet(4);
- Assert.IsTrue(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule2, null, chains)));
+ Assert.True(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule2, null, chains)));
}
- public void TestPolyfillArgumentsComparison5()
+ private void TestPolyfillArgumentsComparison5()
{
String rule = "-A INPUT -m unknown --unknown \'6&0xFF=0x6&&0>>22&0x33@12&0xFFFF=12333\' -g TEST";
IpTablesChainSet chains = new IpTablesChainSet(4);
- Assert.AreEqual(IpTablesRule.Parse(rule, null, chains, 4), IpTablesRule.Parse(rule, null, chains, 4));
+ Assert.Equal(IpTablesRule.Parse(rule, null, chains, 4), IpTablesRule.Parse(rule, null, chains, 4));
}
}
-}
\ No newline at end of file
+}
diff --git a/IPTables.Net.Tests/SingleRecentRuleParseTests.cs b/IPTables.Net.Tests/SingleRecentRuleParseTests.cs
index 9c870ec..db01a6a 100644
--- a/IPTables.Net.Tests/SingleRecentRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleRecentRuleParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleRecentRuleParseTests
+ public class SingleRecentRuleParseTests
{
- [Test]
+ [Fact]
public void TestSet()
{
String rule = "-A ATTK_CHECK -m recent --set --name ATTK";
@@ -15,10 +13,10 @@ public void TestSet()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestUpdate()
{
String rule = "-A ATTK_CHECK -m recent --update --name ATTK --seconds 180 --hitcount 20 -j ATTACKED";
@@ -26,16 +24,16 @@ public void TestUpdate()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestCompare1()
{
String rule = "-A ATTK_CHECK -m recent --rcheck --name BANNED --seconds 180 --reap --rttl -j ATTACKED";
IpTablesChainSet chains = new IpTablesChainSet(4);
- Assert.IsTrue(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule, null, chains, 4)));
+ Assert.True(IpTablesRule.Parse(rule, null, chains, 4).Compare(IpTablesRule.Parse(rule, null, chains, 4)));
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleRejectTargetTests.cs b/IPTables.Net.Tests/SingleRejectTargetTests.cs
index 6074a25..79f7a9b 100644
--- a/IPTables.Net.Tests/SingleRejectTargetTests.cs
+++ b/IPTables.Net.Tests/SingleRejectTargetTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleRejectTargetTests
+ public class SingleRejectTargetTests
{
- [Test]
+ [Fact]
public void TestRejectWithIcmp()
{
String rule = "-A ufw-user-limit -j REJECT --reject-with icmp-port-unreachable";
@@ -15,7 +13,7 @@ public void TestRejectWithIcmp()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleRtsParseTests.cs b/IPTables.Net.Tests/SingleRtsParseTests.cs
index a6166cd..dd4ff7e 100644
--- a/IPTables.Net.Tests/SingleRtsParseTests.cs
+++ b/IPTables.Net.Tests/SingleRtsParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleRtsParseTests
+ public class SingleRtsParseTests
{
- [Test]
+ [Fact]
public void TestSimple()
{
String rule = "-A INPUT -p tcp ! -f -j RTS";
@@ -15,10 +13,10 @@ public void TestSimple()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestWithDest()
{
String rule = "-A INPUT -p tcp ! -f -j RTS --rts-dst 1.1.1.1";
@@ -27,7 +25,7 @@ public void TestWithDest()
IpTablesRule irule1 = IpTablesRule.Parse(rule, null, chains, 4);
IpTablesRule irule2 = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.IsTrue(irule2.Compare(irule1));
+ Assert.True(irule2.Compare(irule1));
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleSdnatRuleParseTests.cs b/IPTables.Net.Tests/SingleSdnatRuleParseTests.cs
index 0d414be..8cd6c25 100644
--- a/IPTables.Net.Tests/SingleSdnatRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleSdnatRuleParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleSdnatRuleParseTests
+ public class SingleSdnatRuleParseTests
{
- [Test]
+ [Fact]
public void TestSnatSingleSource()
{
String rule = "-A PREROUTING -t nat -j SDNAT --to-source 78.141.209.124 --to-destination 104.236.152.141:80 --ctmark 145 --ctmask 1";
@@ -15,7 +13,7 @@ public void TestSnatSingleSource()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
}
diff --git a/IPTables.Net.Tests/SingleSnatRuleParseTests.cs b/IPTables.Net.Tests/SingleSnatRuleParseTests.cs
index ee03144..dde9792 100644
--- a/IPTables.Net.Tests/SingleSnatRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleSnatRuleParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleSnatRuleParseTests
+ public class SingleSnatRuleParseTests
{
- [Test]
+ [Fact]
public void TestSnatSingleSource()
{
String rule = "-A POSTROUTING -t nat -s 1.1.1.1/24 -j SNAT --to-source 2.2.2.2";
@@ -15,10 +13,10 @@ public void TestSnatSingleSource()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestSnatRangeSourceAndEquality()
{
String rule = "-A POSTROUTING -t nat -s 1.1.1.1/24 -j SNAT --to-source 2.2.2.1-2.2.2.250";
@@ -27,9 +25,9 @@ public void TestSnatRangeSourceAndEquality()
IpTablesRule irule1 = IpTablesRule.Parse(rule, null, chains, 4);
IpTablesRule irule2 = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.IsTrue(irule2.Compare(irule1));
- Assert.AreEqual(rule, irule1.GetActionCommand());
- Assert.AreEqual(rule, irule2.GetActionCommand());
+ Assert.True(irule2.Compare(irule1));
+ Assert.Equal(rule, irule1.GetActionCommand());
+ Assert.Equal(rule, irule2.GetActionCommand());
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleStatisticParseTests.cs b/IPTables.Net.Tests/SingleStatisticParseTests.cs
index 3802d16..5953d07 100644
--- a/IPTables.Net.Tests/SingleStatisticParseTests.cs
+++ b/IPTables.Net.Tests/SingleStatisticParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleStatisticParseTests
+ public class SingleStatisticParseTests
{
- [Test]
+ [Fact]
public void TestEvery()
{
String rule = "-A FORWARD -m statistic --mode nth --every 3 --packet 1";
@@ -15,10 +13,10 @@ public void TestEvery()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestRandom()
{
String rule = "-A CHAIN -t raw -m statistic --mode random --probability 0.04";
@@ -26,9 +24,9 @@ public void TestRandom()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestRandomRounding()
{
String rule = "-A CHAIN -t raw -m statistic --mode random --probability 0.03999999911";
@@ -38,9 +36,9 @@ public void TestRandomRounding()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
IpTablesRule irule2 = IpTablesRule.Parse(rule2, null, chains, 4);
- Assert.IsTrue(irule.Compare(irule2));
+ Assert.True(irule.Compare(irule2));
}
- [Test]
+ [Fact]
public void TestRandomRoundingNot()
{
String rule = "-A CHAIN -t raw -m statistic --mode random --probability 0.04";
@@ -51,10 +49,10 @@ public void TestRandomRoundingNot()
IpTablesRule irule2 = IpTablesRule.Parse(rule2, null, chains, 4);
- Assert.AreEqual(irule.GetActionCommand(), irule2.GetActionCommand());
- Assert.IsTrue(irule.Compare(irule2));
+ Assert.Equal(irule.GetActionCommand(), irule2.GetActionCommand());
+ Assert.True(irule.Compare(irule2));
}
- [Test]
+ [Fact]
public void TestRandomRounding2()
{
String rule = "-A CHAIN -t raw -m statistic --mode random ! --probability 0.04";
@@ -65,10 +63,10 @@ public void TestRandomRounding2()
IpTablesRule irule2 = IpTablesRule.Parse(rule2, null, chains, 4);
- Assert.AreEqual(irule.GetActionCommand(), irule2.GetActionCommand());
- Assert.IsTrue(irule.Compare(irule2));
+ Assert.Equal(irule.GetActionCommand(), irule2.GetActionCommand());
+ Assert.True(irule.Compare(irule2));
}
- [Test]
+ [Fact]
public void TestRandomRounding3()
{
String rule = "-A CHAIN -t raw -m statistic --mode random --probability 0.09000000000";
@@ -79,8 +77,8 @@ public void TestRandomRounding3()
IpTablesRule irule2 = IpTablesRule.Parse(rule2, null, chains, 4);
- Assert.AreEqual(irule.GetActionCommand(), irule2.GetActionCommand());
- Assert.IsTrue(irule.Compare(irule2));
+ Assert.Equal(irule.GetActionCommand(), irule2.GetActionCommand());
+ Assert.True(irule.Compare(irule2));
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/SingleTcpRuleParseTests.cs b/IPTables.Net.Tests/SingleTcpRuleParseTests.cs
index f50820f..07cb705 100644
--- a/IPTables.Net.Tests/SingleTcpRuleParseTests.cs
+++ b/IPTables.Net.Tests/SingleTcpRuleParseTests.cs
@@ -1,13 +1,11 @@
using System;
using IPTables.Net.Iptables;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class SingleTcpRuleParseTests
+ public class SingleTcpRuleParseTests
{
- [Test]
+ [Fact]
public void TestDropFragmentedTcpDns()
{
String rule = "-A INPUT -p tcp ! -f -j DROP -m tcp --sport 53";
@@ -15,10 +13,10 @@ public void TestDropFragmentedTcpDns()
IpTablesRule irule = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule.GetActionCommand());
+ Assert.Equal(rule, irule.GetActionCommand());
}
- [Test]
+ [Fact]
public void TestDropFragmentedTcpDnsEquality()
{
String rule = "-A INPUT -p tcp ! -f -j DROP -m tcp --sport 53";
@@ -27,10 +25,10 @@ public void TestDropFragmentedTcpDnsEquality()
IpTablesRule irule1 = IpTablesRule.Parse(rule, null, chains, 4);
IpTablesRule irule2 = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.IsTrue(irule2.Compare(irule1));
+ Assert.True(irule2.Compare(irule1));
}
- [Test]
+ [Fact]
public void TestCoreSportEquality()
{
String rule = "-A INPUT -p tcp -j DROP -m tcp --sport 1";
@@ -39,10 +37,10 @@ public void TestCoreSportEquality()
IpTablesRule irule1 = IpTablesRule.Parse(rule, null, chains, 4);
IpTablesRule irule2 = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.IsTrue(irule2.Compare(irule1));
+ Assert.True(irule2.Compare(irule1));
}
- [Test]
+ [Fact]
public void TestCoreSportZeroValue()
{
String rule = "-A INPUT -p tcp -j DROP -m tcp --sport 0";
@@ -50,7 +48,7 @@ public void TestCoreSportZeroValue()
IpTablesRule irule1 = IpTablesRule.Parse(rule, null, chains, 4);
- Assert.AreEqual(rule, irule1.GetActionCommand());
+ Assert.Equal(rule, irule1.GetActionCommand());
}
}
}
\ No newline at end of file
diff --git a/IPTables.Net.Tests/U32ParserTests.cs b/IPTables.Net.Tests/U32ParserTests.cs
index 031f246..ce24c2f 100644
--- a/IPTables.Net.Tests/U32ParserTests.cs
+++ b/IPTables.Net.Tests/U32ParserTests.cs
@@ -3,83 +3,81 @@
using System.Linq;
using System.Text;
using IPTables.Net.Iptables.U32;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
- internal class U32ParserTests
+ public class U32ParserTests
{
- [TestCase]
+ [Fact]
public void U32RangeParseTest()
{
String str = "1:0x02";
var range = U32Range.Parse(ref str);
- Assert.AreEqual(range.From, 1);
- Assert.AreEqual(range.To, 2);
+ Assert.Equal((uint)1, range.From);
+ Assert.Equal((uint)2, range.To);
}
- [TestCase]
+ [Fact]
public void U32RangeParseSingleTest()
{
String str = "1";
var range = U32Range.Parse(ref str);
- Assert.AreEqual(range.From, 1);
- Assert.AreEqual(range.To, 1);
+ Assert.Equal((uint)1, range.From);
+ Assert.Equal((uint)1, range.To);
}
- [TestCase]
+ [Fact]
public void U32LocationTest()
{
String str = "1>>2";
var range = U32Location.Parse(ref str);
- Assert.AreEqual(range.Location.ToString(), "1");
- Assert.AreEqual(range.Op, U32Location.Operator.Right);
- Assert.AreEqual(range.Number, 2);
+ Assert.Equal("1", range.Location.ToString());
+ Assert.Equal(U32Location.Operator.Right, range.Op);
+ Assert.Equal((uint)2, range.Number);
}
- [TestCase]
+ [Fact]
public void U32LocationTest2()
{
String str = "1@0";
var range = U32Location.Parse(ref str);
- Assert.AreEqual("1", range.Location.ToString());
- Assert.AreEqual(range.Op, U32Location.Operator.Move);
+ Assert.Equal("1", range.Location.ToString());
+ Assert.Equal(U32Location.Operator.Move, range.Op);
}
- [TestCase]
+ [Fact]
public void U32FullTest1()
{
String str = "0 & 0xFFFF = 0x100:0xFFFF";
var range = U32Expression.Parse(str);
- Assert.AreEqual(range, U32Expression.Parse(range.ToString()));
+ Assert.Equal(range, U32Expression.Parse(range.ToString()));
}
- [TestCase]
+ [Fact]
public void U32FullTest2()
{
String str = "6 & 0xFF = 1 && 4 & 0x3FFF = 0 && 0 >> 22 & 0x3C @ 0 >> 24 = 0";
var range = U32Expression.Parse(str);
- Assert.AreEqual(range, U32Expression.Parse(range.ToString()));
+ Assert.Equal(range, U32Expression.Parse(range.ToString()));
}
- [TestCase]
+ [Fact]
public void U32FullTest3()
{
String str = "26 & 0x3C @ 8 = 1,2,5,8";
var range = U32Expression.Parse(str);
- Assert.AreEqual(range, U32Expression.Parse(range.ToString()));
+ Assert.Equal(range, U32Expression.Parse(range.ToString()));
}
- [TestCase]
+ [Fact]
public void U32FullTest4()
{
String str = "6&0xFF=0x6&&0>>22&0x3C@12&0xFFFF=0";
var range = U32Expression.Parse(str);
- Assert.AreEqual(range, U32Expression.Parse(range.ToString()));
+ Assert.Equal(range, U32Expression.Parse(range.ToString()));
}
}
}
diff --git a/IPTables.Net.Tests/UInt32MaskedTests.cs b/IPTables.Net.Tests/UInt32MaskedTests.cs
index a6fa1d7..103e0e0 100644
--- a/IPTables.Net.Tests/UInt32MaskedTests.cs
+++ b/IPTables.Net.Tests/UInt32MaskedTests.cs
@@ -4,18 +4,16 @@
using System.Text;
using System.Threading.Tasks;
using IPTables.Net.Iptables.DataTypes;
-using NUnit.Framework;
namespace IPTables.Net.Tests
{
- [TestFixture]
public class UInt32MaskedTests
{
- [Test]
+ [Fact]
public void TestComparison()
{
- Assert.AreEqual(new UInt32Masked(0, 1), new UInt32Masked(0, 1));
- Assert.AreEqual(new UInt32Masked(1, 1), new UInt32Masked(1, 1));
+ Assert.Equal(new UInt32Masked(0, 1), new UInt32Masked(0, 1));
+ Assert.Equal(new UInt32Masked(1, 1), new UInt32Masked(1, 1));
}
}
}
diff --git a/test.sh b/test.sh
index 016f731..c74a82d 100644
--- a/test.sh
+++ b/test.sh
@@ -168,7 +168,7 @@ run_full_tests() {
cleanup_test_chains
if [[ "$RUN_UNSTABLE_SYSTEM_TESTS" != "1" ]] && ! has_explicit_test_filter; then
- effective_test_args+=("--filter" "TestCategory!=NotWorkingOnTravis")
+ effective_test_args+=("--filter" "Category!=NotWorkingOnTravis")
fi
if [[ "${EUID:-$(id -u)}" -eq 0 ]]; then
@@ -224,7 +224,7 @@ Usage: ./test.sh [--fast|--full] [--iptables-backend ] [--co
Modes:
--fast Skip privileged/system iptables tests by setting SKIP_SYSTEM_TESTS=1.
- --full Run the full NUnit suite, including native helper and system iptables tests.
+ --full Run the full xUnit suite, including native helper and system iptables tests.
Backend selection:
--iptables-backend legacy Use iptables-legacy/ip6tables-legacy for full-system tests. This is the default.