public void testFindUrl_MultiSite4()
        {
            // test that url is not switched when errors reported but then succes resets count
            Dictionary <string, string> _config = new Dictionary <string, string>
            {
                { "proxyHost", "websenseproxy" },
                { "proxyPort", "8080" },
                { "printxml", "false" },
                { "merchantId", "101" },
                { "username", "DOTNET" },
                { "password", "TESTCASE" },

                { "multiSite", "true" },
                { "printMultiSiteDebug", "false" },
                { "url", legacyUrl },
                { "multiSiteUrl1", site1Url },
                { "multiSiteUrl2", site2Url },
                { "multiSiteErrorThreshold", "3" },
                { "maxHoursWithoutSwitch", "0" }
            };

            CommManager.reset();
            CommManager cmg = CommManager.instance(_config);

            Assert.IsNotNull(cmg);
            Assert.IsTrue(cmg.getMultiSite());
            Assert.AreEqual(cmg.getMultiSiteThreshold(), 3);

            RequestTarget rt1 = cmg.findUrl();

            Assert.AreEqual(cmg.getMultiSiteUrls()[cmg.getCurrentMultiSiteUrlIndex()], rt1.getUrl());
            cmg.reportResult(rt1, CommManager.REQUEST_RESULT_RESPONSE_TIMEOUT, 0);
            RequestTarget rt2 = cmg.findUrl();

            Assert.AreEqual(rt1.getUrl(), rt2.getUrl());
            cmg.reportResult(rt2, CommManager.REQUEST_RESULT_RESPONSE_RECEIVED, 200);
            Assert.AreEqual(0, cmg.getErrorCount());

            RequestTarget rt3 = cmg.findUrl();

            Assert.AreEqual(rt1.getUrl(), rt3.getUrl());
            cmg.reportResult(rt3, CommManager.REQUEST_RESULT_RESPONSE_RECEIVED, 301);
            Assert.AreEqual(0, cmg.getErrorCount());
        }
        public void testFindUrl_MultiSite3()
        {
            // test that url is switched when errors reach threshold and switched again after errors
            Dictionary <string, string> _config = new Dictionary <string, string>
            {
                { "proxyHost", "websenseproxy" },
                { "proxyPort", "8080" },
                { "printxml", "false" },
                { "merchantId", "101" },
                { "username", "DOTNET" },
                { "password", "TESTCASE" },

                { "multiSite", "true" },
                { "printMultiSiteDebug", "false" },
                { "url", legacyUrl },
                { "multiSiteUrl1", site1Url },
                { "multiSiteUrl2", site2Url },
                { "multiSiteErrorThreshold", "3" },
                { "maxHoursWithoutSwitch", "48" }
            };

            CommManager.reset();
            CommManager cmg = CommManager.instance(_config);

            Assert.IsNotNull(cmg);
            Assert.IsTrue(cmg.getMultiSite());
            Assert.AreEqual(cmg.getMultiSiteThreshold(), 3);

            RequestTarget rt1 = cmg.findUrl();

            Assert.AreEqual(cmg.getMultiSiteUrls()[cmg.getCurrentMultiSiteUrlIndex()], rt1.getUrl());
            cmg.reportResult(rt1, CommManager.REQUEST_RESULT_RESPONSE_TIMEOUT, 0);
            RequestTarget rt2 = cmg.findUrl();

            Assert.AreEqual(rt1.getUrl(), rt2.getUrl());
            cmg.reportResult(rt2, CommManager.REQUEST_RESULT_RESPONSE_TIMEOUT, 0);
            RequestTarget rt3 = cmg.findUrl();

            Assert.AreEqual(rt1.getUrl(), rt3.getUrl());
            cmg.reportResult(rt3, CommManager.REQUEST_RESULT_RESPONSE_TIMEOUT, 0);
            Assert.AreEqual(cmg.getErrorCount(), 3);

            RequestTarget rt4 = cmg.findUrl();

            Assert.IsFalse(rt4.getUrl().Equals(rt1.getUrl()));

            RequestTarget rt10 = cmg.findUrl();

            Assert.AreEqual(cmg.getMultiSiteUrls()[cmg.getCurrentMultiSiteUrlIndex()], rt10.getUrl());
            cmg.reportResult(rt10, CommManager.REQUEST_RESULT_RESPONSE_RECEIVED, 401);
            RequestTarget rt11 = cmg.findUrl();

            Assert.AreEqual(rt10.getUrl(), rt11.getUrl());
            cmg.reportResult(rt11, CommManager.REQUEST_RESULT_CONNECTION_FAILED, 0);
            RequestTarget rt12 = cmg.findUrl();

            Assert.AreEqual(rt11.getUrl(), rt12.getUrl());
            cmg.reportResult(rt12, CommManager.REQUEST_RESULT_RESPONSE_TIMEOUT, 0);
            Assert.AreEqual(cmg.getErrorCount(), 3);

            RequestTarget rt13 = cmg.findUrl();

            Assert.IsFalse(rt13.getUrl().Equals(rt11.getUrl()));
            Assert.IsTrue(rt13.getUrl().Equals(rt1.getUrl()));
        }