public void TearDown()
        {
            try
            {
                var rulesToBeDeleted = _firewall.Rules.Where(rule => rule.Name.StartsWith(RulesPrefix)).ToArray();

                foreach (var firewallRule in rulesToBeDeleted)
                {
                    _firewall.Rules.Remove(firewallRule);
                }
            }
            catch (Exception)
            {
                // ignored
            }

            _firewall = null;
        }
        public FirewallLegacyRulesCollection(FirewallLegacyProfile[] profiles, FirewallLegacy firewall)
        {
            _firewall = firewall;
            _firewallPortCollections = profiles.ToDictionary(
                profile => profile.Type,
                profile => new FirewallLegacyPortCollection(profile.UnderlyingObject.GloballyOpenPorts)
                );

            _firewallApplicationCollections = profiles.ToDictionary(
                profile => profile.Type,
                profile => new FirewallLegacyApplicationCollection(profile.UnderlyingObject.AuthorizedApplications)
                );

            _firewallServiceCollections = profiles.ToDictionary(
                profile => profile.Type,
                profile => new FirewallLegacyServiceCollection(profile.UnderlyingObject.Services)
                );
        }
 public void Setup()
 {
     _firewall = FirewallLegacy.Instance;
 }