public void IsLinkDomainForbidden_CurrentDomainParam_ReturnFilteredLinks()
        {
            var links = new List <Uri>()
            {
                new Uri("https://linkmanagertests.com/buttons.css"),
                new Uri("https://linkmanagertests.com/home"),
                new Uri("https://linkmanagertests.com/img/hello/hello.png"),
                new Uri("https://habr.com"),
                new Uri("https://epam.com"),
                new Uri("https://linkmanagertests.com/scripts/script.js")
            };
            var currentDomain = new Uri("https://linkmanagertests.com");

            bool[] expected = { false, false, false, true, true, false };
            DomainSwitchParameter domainSwitchParameter = DomainSwitchParameter.CurrentDomain;
            HtmlLinkManager       linkManager           = new HtmlLinkManager(domainSwitchParameter: domainSwitchParameter);

            var actual = links.Select(link => linkManager.IsLinkDomainForbidden(currentDomain, link)).ToList();

            CollectionAssert.AreEqual(expected, actual);
        }
        public void IsLinkDomainForbidden_BelowSourceUrlPath_ReturnFilteredLinks()
        {
            var links = new List <Uri>()
            {
                new Uri("https://linkmanagertests.com/users/index.html"),
                new Uri("https://linkmanagertests.com/home"),
                new Uri("https://linkmanagertests.com/"),//should it pass?
                new Uri("https://habr.com"),
                new Uri("https://epam.com"),
                new Uri("https://linkmanagertests.com/scripts/script.js")
            };
            var baseUrl = new Uri("https://linkmanagertests.com/users");

            bool[] expected = { false, true, true, true, true, true };

            DomainSwitchParameter domainSwitchParameter = DomainSwitchParameter.BelowSourceUrlPath;
            HtmlLinkManager       linkManager           = new HtmlLinkManager(domainSwitchParameter: domainSwitchParameter);

            var result = links.Select(link => linkManager.IsLinkDomainForbidden(baseUrl, link)).ToList();

            CollectionAssert.AreEqual(expected, result);
        }
 public HtmlLinkManager(IEnumerable <string> excludedFromSearchExtensions = null,
                        DomainSwitchParameter domainSwitchParameter       = DomainSwitchParameter.WithoutRestrictions)
 {
     _excludedExtensions    = excludedFromSearchExtensions ?? new List <string>();
     _domainSwitchParameter = domainSwitchParameter;
 }
 public HtmlLinkManager()
 {
     _excludedExtensions    = new List <string>();
     _domainSwitchParameter = DomainSwitchParameter.WithoutRestrictions;
 }