-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMockIpsetSystemFactory.cs
More file actions
36 lines (31 loc) · 1.03 KB
/
MockIpsetSystemFactory.cs
File metadata and controls
36 lines (31 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using SystemInteract;
using IPTables.Net.IpSet;
namespace IPTables.Net.TestFramework
{
public class MockIpsetSystemFactory : ISystemFactory
{
public List<KeyValuePair<String, String>> Commands = new List<KeyValuePair<string, string>>();
public ISystemProcess StartProcess(string command, string arguments)
{
Commands.Add(new KeyValuePair<string, string>(command, arguments));
return new MockIptablesSystemProcess();
}
public Stream Open(string path, FileMode mode, FileAccess access)
{
throw new NotImplementedException();
}
public void TestSync(IpSetSets rulesNew)
{
rulesNew.Sync((a)=>true, false);
}
public void TestSync(IpSetSets rulesNew, List<string> expectedCommands)
{
TestSync(rulesNew);
Assert.Equal(expectedCommands, Commands.Select(a => a.Value).ToList());
}
}
}