public void TestSimpleDelete4() { var log = new BdoLog(); string expectedResult = @"delete from ""Mdm"".""Employee"" where ""Code""='codeC'"; string result = _repository.Connector.CreateCommandText(_repository.Model.DeleteEmployee4("codeC"), log: log); string xml = ""; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml(); } Assert.That(result.Trim().Equals(expectedResult.Trim(), StringComparison.OrdinalIgnoreCase), "Bad script interpretation" + xml); }
public void SimpleSelect7() { var log = new BdoLog(); string expectedResult = @"select ""employee"".*, ""contact"".""Code"" as ""contactCode"", ""regionalDirectorate"".""RegionalDirectorateId"", ""regionalDirectorate"".""Code"", now() from ""Mdm"".""Employee"""; string result = _dbConnector.CreateCommandText(_model.SelectEmployeeWithCode6("codeC"), log: log); string xml = ""; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml(); } Assert.That(result.Trim().Equals(expectedResult.Trim(), StringComparison.OrdinalIgnoreCase), "Bad script interpretation" + xml); }
public void SimpleSelect4() { var log = new BdoLog(); string expectedResult = @"with ""directorate"" as (select * from ""Mdm"".""RegionalDirectorate"" ) select ""Mdm"".""Employee"".*, ""Mdm"".""RegionalDirectorate"".""RegionalDirectorateId"", ""Mdm"".""RegionalDirectorate"".""Code"" from ""Mdm"".""Employee"" left join ""Mdm"".""RegionalDirectorate"" as ""directorate"" on (""Mdm"".""Employee"".""EmployeeId""=""directorate"".""RegionalDirectorateId"") where ""Code""='codeC' limit 100"; string result = _dbConnector.CreateCommandText(_model.SelectEmployeeWithCode4("codeC"), log: log); string xml = ""; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml(); } Assert.That(result.Trim().Equals(expectedResult.Trim(), StringComparison.OrdinalIgnoreCase), "Bad script interpretation" + xml); }
public void SaveUsableConfigurationTest() { var log = new BdoLog(); _usableConfiguration1.SaveXml(_filePath1, log); _usableConfiguration20.SaveXml(_filePath20, log); _usableConfiguration21.SaveXml(_filePath21, log); string xml = string.Empty; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml() + "'"; } Assert.That(!log.HasErrorsOrExceptions(), "Usable configuration saving failed" + xml); }
public void TestSimpleDelete8() { var log = new BdoLog(); string expectedResult = @"delete from ""Mdm"".""Employee"" using ""Mdm"".""RegionalDirectorate"" as ""directorate"", ""Mdm"".""Contact"", ""Mdm"".""Contact"" as ""secondaryCountry"" where (((""Code""='codeC' and (""Mdm"".""Employee"".""EmployeeId""=""Mdm"".""RegionalDirectorate"".""RegionalDirectorateId"")) and (""Mdm"".""Employee"".""MainContactId""=""Mdm"".""Contact"".""ContactId"")) and (""secondary"".""MainContactId""=""Mdm"".""Contact"".""ContactId""))"; string result = _repository.Connector.CreateCommandText(_repository.Model.DeleteEmployee8("codeC"), log: log); string xml = ""; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml(); } Assert.That(result.Trim().Equals(expectedResult.Trim(), StringComparison.OrdinalIgnoreCase), "Bad script interpretation" + xml); }
public void TestSqlValue() { var expression = DbFluent.Value(_value_datetime); var log = new BdoLog(); string expectedResult = @"$sqlValue('2020-12-20T00:00:00')"; string result = (string)expression; string xml = ""; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml(); } Assert.That(result.Trim().Equals(expectedResult.Trim(), StringComparison.OrdinalIgnoreCase), "Bad script interpretation" + xml); }
public void SimpleUpdate2() { var log = new BdoLog(); string expectedResult = @"update ""Mdm"".""Employee"" as ""employee"" set ""RegionalDirectorateId""=null from ""Mdm"".""RegionalDirectorate"" as ""regionalDirectorate"" where ""employee"".""RegionalDirectorateId""=""regionalDirectorate"".""RegionalDirectorateId"" and ""employee"".""Code""='codeC' returning ""employee"".""Code"""; string result = _dbConnector.CreateCommandText(_model.UpdateEmployee2("codeC"), log: log); string xml = ""; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml(); } Assert.That(result.Trim().Equals(expectedResult.Trim(), StringComparison.OrdinalIgnoreCase), "Bad script interpretation" + xml); }
public void SaveConnectorTest() { if (_connector == null) { CreateConnectorTest(); } var log = new BdoLog(); _connector.SaveXml(_filePath, log); string xml = string.Empty; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml() + "'"; } Assert.That(!log.HasErrorsOrExceptions(), "Connector saving failed" + xml); }
public void SaveDatasourceDepotTest() { var log = new BdoLog(); if (_datasourceDepot == null) { CreateDatasourceDataStoreTest(); } _datasourceDepot.SaveXml(_filePath, log); string xml = string.Empty; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml() + "'"; } Assert.That(!log.HasErrorsOrExceptions(), "Data source depots saving failed" + xml); }
public void CreateOpenCloseConnectionTest() { BdoLog log = new BdoLog(); // check bad connection using (var connection = _connector?.CreateConnection(log)) { connection.Disconnect(); } string xml = string.Empty; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml() + "'"; } Assert.That(!log.HasErrorsOrExceptions(), "Connection creation failed" + xml); }
public void SaveDictionaryTest() { if (_dictionary == null) { CreateDictionaryTest(); } var log = new BdoLog(); _dictionary.SaveXml(_filePath, log); string xml = string.Empty; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml() + "'"; } Assert.That(!log.HasErrorsOrExceptions(), "Element set saving failed" + xml); }
public void TestSqlStringConcat() { var expression = DbFluent.StringConcat("X", "O", "A"); var log = new BdoLog(); string expectedResult = @"'X' || 'O' || 'A'"; var result = _appHost.Interpreter.Evaluate <string>( expression, new ScriptVariableSet().SetDbBuilder(new DbQueryBuilder_PostgreSql()), log: log); var xml = ""; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml(); } Assert.That(result.Trim().Equals(expectedResult.Trim(), StringComparison.OrdinalIgnoreCase), "Bad script interpretation" + xml); }
public void LoadDataElementSetTest() { if (_carrierElementSet == null || !File.Exists(_filePath)) { SaveDataElementSetTest(); } var log = new BdoLog(); var elementSet = XmlHelper.Load <DataElementSet>(_filePath, log: log); string xml = string.Empty; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml() + "'"; } Assert.That(!log.HasErrorsOrExceptions(), "Element set loading failed" + xml); Test(elementSet); }
public void LoadConfigurationTest() { if (_carrier == null || !File.Exists(_filePath)) { SaveCarrierTest(); } var log = new BdoLog(); BdoCarrierConfiguration configuration = XmlHelper.Load <BdoCarrierConfiguration>(_filePath, log: log); var field = GlobalVariables.Scope.CreateCarrier <CarrierFake>(configuration, null, log); string xml = string.Empty; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml() + "'"; } Assert.That(!log.HasErrorsOrExceptions(), "Carrier loading failed" + xml); Test(field); }
public void LoadDatasourceDepotTest() { var log = new BdoLog(); if (_datasourceDepot == null || !File.Exists(_filePath)) { SaveDatasourceDepotTest(); } var datasourceDepot = XmlHelper.Load <BdoDatasourceDepot>(_filePath, log: log); string xml = string.Empty; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml() + "'"; } Assert.That(!log.HasErrorsOrExceptions(), "Data source depot loading failed" + xml); TestDatasourceDataStore(datasourceDepot); }
public void SaveDataElementSetTest() { if (_carrierElementSet == null) { CreateCarrierElementSetTest(); } var log = new BdoLog(); _carrierElementSet.SaveXml(_filePath, log); string xml = string.Empty; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml() + "'"; } Assert.That(!log.HasErrorsOrExceptions(), "Element set saving failed" + xml); Test(_carrierElementSet); }
public void LoadEventsTest() { if (_log == null || !File.Exists(_filePath)) { CreateEventsTest(); } BdoLog log = new BdoLog(); _log = XmlHelper.Load <BdoLog>(_filePath, log: log); string xml = string.Empty; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml() + "'"; } Assert.That(!log.HasErrorsOrExceptions(), "Error while loading log" + xml); Test(_log); }
public void LoadConfigurationTest() { var log = new BdoLog(); if (_connector == null || !File.Exists(_filePath)) { SaveConnectorTest(); } string xml = string.Empty; BdoConnectorConfiguration configuration = XmlHelper.Load <BdoConnectorConfiguration>(_filePath, log: log); ConnectorFake connector = GlobalVariables.Scope.CreateConnector <ConnectorFake>(configuration, null, log); if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml() + "'"; } Assert.That(!log.HasErrorsOrExceptions(), "Connector loading failed" + xml); Test(connector); }
public void TestInterprete_Fun_SqlULPad() { var log = new BdoLog(); string fluentScript = DbFluent.LeftPadding(DbFluent.Field("RegionalDirectorateId"), 10, DbFluent.Text("A")); var scriptVariableSet = new ScriptVariableSet(); scriptVariableSet.SetValue(VarSetDb.__DbBuilder, DbQueryFactory.CreateQueryBuilder <DbQueryBuilder_PostgreSql>(GlobalVariables.AppHost)); string result = GlobalVariables.AppHost.Scope.Interpreter.Evaluate(fluentScript, DataExpressionKind.Script, scriptVariableSet, log: log)?.ToString(); string expectedResult = @"lpad(""RegionalDirectorateId"", 10, 'A')"; string xml = ""; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml(); } Assert.That(result.Trim().Equals(expectedResult.Trim(), StringComparison.OrdinalIgnoreCase), "Bad script interpretation" + xml); }
public void SimpleInsertWithValues() { var log = new BdoLog(); string expectedResult = @"insert into ""Mdm"".""Employee"" (""Code"", ""ByteArrayField"", ""DoubleField"", ""DateTimeField"", ""LongField"") " + "(values ('" + _employee.Code.Replace("'", "''") + "'" + ", '" + _employee.ByteArrayField.ToString(DataValueTypes.ByteArray).Replace("'", "''") + "'" + ", " + _employee.DoubleField.ToString(DataValueTypes.Number) + ", '" + _employee.DateTimeField.ToString(DataValueTypes.Date) + "'" + ", " + _employee.LongField.ToString(DataValueTypes.Long) + @"))" + @" returning ""Mdm"".""Employee"".""EmployeeId"""; string result = _dbConnector.CreateCommandText(_model.InsertEmployee1(_employee), log: log); string xml = ""; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml(); } Assert.That(result.Trim().Equals(expectedResult.Trim(), StringComparison.OrdinalIgnoreCase), "Bad script interpretation" + xml); }
public void TestInterprete_Fun_SqlIf() { string value = null; string script1 = DbFluent.If(DbFluent.IsNull(value), DbFluent.Field("RegionalDirectorateId"), DbFluent.Field("RegionalDirectorateId2")); string expectedResult = @"case when (null is null) then ""RegionalDirectorateId"" else ""RegionalDirectorateId2"" end"; 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(script1, 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); }
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); }
public void TestSqlIfNull() { var expression = DbFluent.Eq( DbFluent.Field("fieldA"), DbFluent.IfNull( DbFluent.Parameter("myText"), DbFluent.Field("fieldA"))); var log = new BdoLog(); string expectedResult = @"""fieldA""=coalesce(|*|p:myText|*|, ""fieldA"")"; var result = _appHost.Interpreter.Evaluate <string>( expression, new ScriptVariableSet().SetDbBuilder(new DbQueryBuilder_PostgreSql()), log: log); var xml = ""; if (log.HasErrorsOrExceptions()) { xml = ". Result was '" + log.ToXml(); } Assert.That(result.Trim().Equals(expectedResult.Trim(), StringComparison.OrdinalIgnoreCase), "Bad script interpretation" + xml); }