Ejemplo n.º 1
0
        public void TestInterprete_Fun_SqlEncode()
        {
            string script         = DbFluent.EncodeBase64(DbFluent.Text("ABCDE"));
            string expectedResult = @"encode('ABCDE', 'base64')";

            var log = new BdoLog();

            var scriptVariableSet = new ScriptVariableSet();

            scriptVariableSet.SetValue(VarSetDb.__DbBuilder,
                                       DbQueryFactory.CreateQueryBuilder <DbQueryBuilder_PostgreSql>(GlobalVariables.AppHost));
            string result = GlobalVariables.AppHost.Scope.Interpreter.Evaluate(script, DataExpressionKind.Script, scriptVariableSet, log: log)?.ToString();

            string xml = "";

            if (log.HasErrorsOrExceptions())
            {
                xml = ". Result was '" + log.ToXml();
            }
            Assert.That(result.Trim().Equals(expectedResult.Trim(), StringComparison.OrdinalIgnoreCase), "Bad script interpretation" + xml);

            script         = DbFluent.DecodeBase64(DbFluent.Field("ABCDE"));
            expectedResult = @"decode(""ABCDE"", 'base64')";
            log            = new BdoLog();

            scriptVariableSet = new ScriptVariableSet();
            scriptVariableSet.SetValue(VarSetDb.__DbBuilder,
                                       DbQueryFactory.CreateQueryBuilder <DbQueryBuilder_PostgreSql>(GlobalVariables.AppHost));
            result = GlobalVariables.AppHost.Scope.Interpreter.Evaluate(script, DataExpressionKind.Script, scriptVariableSet, log: log)?.ToString();

            xml = "";
            if (log.HasErrorsOrExceptions())
            {
                xml = ". Result was '" + log.ToXml();
            }
            Assert.That(result.Trim().Equals(expectedResult.Trim(), StringComparison.OrdinalIgnoreCase), "Bad script interpretation" + xml);
        }