public void TestPerformanceImpact()
        {
            using var repo    = new SqlRewriteDbRepository(Settings.Default.ConnectionString);
            using var service = new SqlRewriteRuleService(repo, true);
            using var conn    = new SqlConnection(Settings.Default.ConnectionString);
            conn.Open();
            var stopWatch = new Stopwatch();

            stopWatch.Start();
            Assert.AreNotEqual(0, service.AddRule(".*", Stm, "SELECT GETDATE()"));
            service.RefreshRulesFromRepository();
            for (var i = 0; i < 10000; i++)
            {
                using var cmd = new SqlCommand(Stm, conn);
                var version = cmd.ExecuteScalar().ToString();
                Assert.IsNotNull(version.Contains("Microsoft"));
            }
            stopWatch.Stop();
            var intervalFullInjection = stopWatch.Elapsed;

            stopWatch.Reset();
            stopWatch.Start();
            service.Enabled = false;
            for (var i = 0; i < 10000; i++)
            {
                using var cmd = new SqlCommand(Stm, conn);
                var version = cmd.ExecuteScalar().ToString();
                Assert.IsNotNull(version.Contains("Microsoft"));
            }
            stopWatch.Stop();
            Assert.IsTrue(Math.Abs(intervalFullInjection.TotalMilliseconds / stopWatch.Elapsed.TotalMilliseconds) < 3, $"{intervalFullInjection.TotalMilliseconds} vs {stopWatch.Elapsed.TotalMilliseconds}");
        }
        public void TestBasicSqlRewriteRuleService()
        {
            using var conn = new SqlConnection(Settings.Default.ConnectionString);
            var repo = new SqlRewriteDbRepository(conn);
            var rule = new SqlRewriteRule
            {
                DatabaseRegEx = ".*", QueryMatchRegEx = Stm, QueryReplacementString = "SELECT GETDATE()"
            };

            repo.SaveSqlRewriteRule(rule);
            using var service = new SqlRewriteRuleService(repo, true);
            using var con     = new SqlConnection(Settings.Default.ConnectionString);
            con.Open();
            using var cmd = new SqlCommand(Stm, con);
            var version = cmd.ExecuteScalar().ToString();

            Assert.IsFalse(version.Contains("Microsoft"));
            service.RemoveRule(rule.Id);
            service.RefreshRulesFromRepository();
            using var con2 = new SqlConnection(Settings.Default.ConnectionString);
            con2.Open();
            using var cmd2 = new SqlCommand(Stm, con2);
            version        = cmd2.ExecuteScalar().ToString();
            Assert.IsTrue(version.Contains("Microsoft"));
        }