Пример #1
0
        public void TestGetMatchingRulesForEvent()
        {
            string exePath = @"C:\Windows\System32\svchost.exe";
            IEnumerable <FirewallHelper.Rule> results = FirewallHelper.GetMatchingRulesForEvent(pid: 0, path: exePath, target: "*", targetPort: "*", blockOnly: false);

            Assert.NotNull(results);
            Assert.True(results.ToList().Count >= 1, "Has no results or number of results does not match");
            foreach (FirewallHelper.Rule rule in results)
            {
                Console.WriteLine($"{rule.Name}, {rule.RemoteAddresses}");
            }
        }