diff --git a/build.proj b/build.proj
index c4b69617..00f12435 100644
--- a/build.proj
+++ b/build.proj
@@ -35,56 +35,31 @@
source\fitSharp\bin\release\net48\fitSharp.dll;
source\fit\bin\release\net48\fit.dll;
source\Runner\bin\release\net48\Runner.exe;
- source\RunnerW\bin\release\net48\RunnerW.exe;
- source\dbfit\bin\release\net48\dbfit.dll;
- source\dbfitMySql\bin\release\net48\dbfit.mysql.dll;
- source\dbfitOracle\bin\release\net48\dbfit.oracle.dll;
- source\dbfitSqlServer\bin\release\net48\dbfit.sqlserver.dll;
- source\dbfitSybase\bin\release\net48\dbfit.sybase.dll;"/>
+ source\RunnerW\bin\release\net48\RunnerW.exe"/>
+ source\Runner\bin\release\net8.0\Runner.runtimeconfig.json"/>
+ source\RunnerW\bin\release\net8.0-windows\RunnerW.runtimeconfig.json"/>
+ source\Runner\bin\release\net9.0\Runner.runtimeconfig.json"/>
+ source\RunnerW\bin\release\net9.0-windows\RunnerW.runtimeconfig.json"/>
diff --git a/fitSharp.sln b/fitSharp.sln
index 16a4e3fa..2ecc15b4 100644
--- a/fitSharp.sln
+++ b/fitSharp.sln
@@ -17,18 +17,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "fitTest", "source\fitTest\f
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Runner", "source\Runner\Runner.csproj", "{2EB7CA6D-7373-48E5-97C0-D98E1560E161}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dbfit", "source\dbfit\dbfit.csproj", "{6F72A0B4-EAB2-410A-945D-4C4D04B18893}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dbfitMySql", "source\dbfitMySql\dbfitMySql.csproj", "{0E54698B-0BF7-4413-9E4C-C807E346CD11}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dbfitOracle", "source\dbfitOracle\dbfitOracle.csproj", "{F38C6772-3B92-4E10-9ED4-D37BE35D2303}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dbfitSqlServer", "source\dbfitSqlServer\dbfitSqlServer.csproj", "{CF0CAD84-0102-4C7C-BA8C-572111FF6899}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dbfitSybase", "source\dbfitSybase\dbfitSybase.csproj", "{94F5FD4F-C6C9-4D60-94BF-13974F780A3E}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "dbfitTest", "source\dbfitTest\dbfitTest.csproj", "{383E3568-AEEE-4F95-8D87-355D891DB36F}"
-EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RunnerW", "source\RunnerW\RunnerW.csproj", "{73A6C8F9-FB51-4D17-9BED-4BE0785CD5B0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TestTarget2", "source\TestTarget2\TestTarget2.csproj", "{538B8011-B247-46EC-A9AB-29BC5262A543}"
@@ -69,30 +57,6 @@ Global
{2EB7CA6D-7373-48E5-97C0-D98E1560E161}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2EB7CA6D-7373-48E5-97C0-D98E1560E161}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2EB7CA6D-7373-48E5-97C0-D98E1560E161}.Release|Any CPU.Build.0 = Release|Any CPU
- {6F72A0B4-EAB2-410A-945D-4C4D04B18893}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {6F72A0B4-EAB2-410A-945D-4C4D04B18893}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {6F72A0B4-EAB2-410A-945D-4C4D04B18893}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {6F72A0B4-EAB2-410A-945D-4C4D04B18893}.Release|Any CPU.Build.0 = Release|Any CPU
- {0E54698B-0BF7-4413-9E4C-C807E346CD11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {0E54698B-0BF7-4413-9E4C-C807E346CD11}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {0E54698B-0BF7-4413-9E4C-C807E346CD11}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {0E54698B-0BF7-4413-9E4C-C807E346CD11}.Release|Any CPU.Build.0 = Release|Any CPU
- {F38C6772-3B92-4E10-9ED4-D37BE35D2303}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {F38C6772-3B92-4E10-9ED4-D37BE35D2303}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {F38C6772-3B92-4E10-9ED4-D37BE35D2303}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {F38C6772-3B92-4E10-9ED4-D37BE35D2303}.Release|Any CPU.Build.0 = Release|Any CPU
- {CF0CAD84-0102-4C7C-BA8C-572111FF6899}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {CF0CAD84-0102-4C7C-BA8C-572111FF6899}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {CF0CAD84-0102-4C7C-BA8C-572111FF6899}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {CF0CAD84-0102-4C7C-BA8C-572111FF6899}.Release|Any CPU.Build.0 = Release|Any CPU
- {94F5FD4F-C6C9-4D60-94BF-13974F780A3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {94F5FD4F-C6C9-4D60-94BF-13974F780A3E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {94F5FD4F-C6C9-4D60-94BF-13974F780A3E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {94F5FD4F-C6C9-4D60-94BF-13974F780A3E}.Release|Any CPU.Build.0 = Release|Any CPU
- {383E3568-AEEE-4F95-8D87-355D891DB36F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {383E3568-AEEE-4F95-8D87-355D891DB36F}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {383E3568-AEEE-4F95-8D87-355D891DB36F}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {383E3568-AEEE-4F95-8D87-355D891DB36F}.Release|Any CPU.Build.0 = Release|Any CPU
{73A6C8F9-FB51-4D17-9BED-4BE0785CD5B0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73A6C8F9-FB51-4D17-9BED-4BE0785CD5B0}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73A6C8F9-FB51-4D17-9BED-4BE0785CD5B0}.Release|Any CPU.ActiveCfg = Release|Any CPU
diff --git a/source/dbfit/Properties/AssemblyInfo.cs b/source/dbfit/Properties/AssemblyInfo.cs
deleted file mode 100644
index 1a0a723c..00000000
--- a/source/dbfit/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle("DbFit for fitSharp")]
-[assembly: AssemblyDescription("DbFit. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.")]
-[assembly: AssemblyProduct("fitSharp")]
-[assembly: ComVisible(false)]
-
-[assembly: AssemblyCopyright("Copyright © 2007 Gojko Adzic, 2022 Syterra Software Inc. All rights reserved.")]
-[assembly: AssemblyVersion("2022.1.15.0")]
diff --git a/source/dbfit/dbfit.csproj b/source/dbfit/dbfit.csproj
deleted file mode 100644
index e7fbd7e2..00000000
--- a/source/dbfit/dbfit.csproj
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
- net48;net8.0;net8.0-windows;net9.0;net9.0-windows
- dbfit
- false
- false
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/source/dbfit/environment/AbstractDbEnvironment.cs b/source/dbfit/environment/AbstractDbEnvironment.cs
deleted file mode 100644
index 24ecce6b..00000000
--- a/source/dbfit/environment/AbstractDbEnvironment.cs
+++ /dev/null
@@ -1,233 +0,0 @@
-// Copyright © 2015 Syterra Software Inc. Includes work Copyright (C) Gojko Adzic 2006-2008 http://gojko.net
-// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.
-// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-using System;
-using System.Collections.Generic;
-using System.Configuration;
-using System.Data.Common;
-using System.Data;
-using System.Text.RegularExpressions;
-using System.Text;
-using dbfit.util;
-using fitSharp.Machine.Engine;
-
-namespace dbfit
-{
- ///
- /// Utility class to simplify development of IDbEnvironment implementations. This class
- /// has implementations for methods that will be common across most databases. It also provides
- /// default accessors for the current connection and transaction.
- ///
- public abstract class AbstractDbEnvironment : IDbEnvironment
- {
- ///
- /// optional prefix symbol that is added to parameter names in Sql commands.
- ///
- public abstract String ParameterPrefix { get; }
-
- #region default implementations for IDbEnvironment methods and properties
-
- private IDbConnection _currentConnection;
- private IDbTransaction _currentTransaction;
-
- public IDbConnection CurrentConnection
- {
- get
- {
- return _currentConnection;
- }
- protected set
- {
- _currentConnection = value;
- }
- }
- public IDbTransaction CurrentTransaction
- {
- get
- {
- return _currentTransaction;
- }
- protected set
- {
- _currentTransaction = value;
- }
- }
-
- public virtual void Connect(String dataSource, String username, String password, String database)
- {
- Connect(GetConnectionString(dataSource, username, password, database));
- }
- public virtual void Connect(String dataSource, String username, String password)
- {
- Connect(GetConnectionString(dataSource, username, password));
- }
- public virtual void Connect(String connectionString)
- {
- CurrentConnection = DbProviderFactory.CreateConnection();
- CurrentConnection.ConnectionString = connectionString;
- CurrentConnection.Open();
- CurrentTransaction = CurrentConnection.BeginTransaction();
- }
- public virtual void ConnectUsingFile(String connectionPropertiesFile)
- {
- DbConnectionProperties dbp = DbConnectionProperties.CreateFromFile(connectionPropertiesFile);
- if (dbp.FullConnectionString != null) Connect(dbp.FullConnectionString);
- else if (dbp.DbName != null) Connect(dbp.Service, dbp.Username, dbp.Password, dbp.DbName);
- else Connect(dbp.Service, dbp.Username, dbp.Password);
- }
-
- public virtual void ConnectUsingConfig(string connectionName) {
- var fullConnectionString = ConfigurationManager.ConnectionStrings[connectionName].ConnectionString;
-
- if (fullConnectionString == null) {
- throw new Exception(string.Format("No Connection String found for {0}", connectionName));
- }
- Connect(fullConnectionString);
- }
-
- public virtual void ConnectNoTransaction(String dataSource, String username, String password, String database)
- {
- string connectionString = GetConnectionString(dataSource, username, password, database);
- CurrentConnection = DbProviderFactory.CreateConnection();
- CurrentConnection.ConnectionString = connectionString;
- CurrentConnection.Open();
- }
- protected virtual void AddInput(IDbCommand dbCommand, String name, Object value)
- {
- var dbParameter = dbCommand.CreateParameter();
- dbParameter.Direction = ParameterDirection.Input;
- dbParameter.ParameterName = name;
- dbParameter.Value = (value == null ? DBNull.Value : value);
- dbCommand.Parameters.Add(dbParameter);
- }
-
- public virtual IDbCommand CreateCommand(string statement, CommandType commandType)
- {
- if (CurrentConnection == null) throw new ApplicationException("Not connected to database");
-
- var dc = CurrentConnection.CreateCommand();
- dc.CommandText = statement.Replace("\r", " ").Replace("\n", " ");
- dc.CommandType = commandType;
- dc.Transaction = CurrentTransaction;
- dc.CommandTimeout = Options.CommandTimeOut;
- return dc;
- }
- public virtual void BindFixtureSymbols(Symbols symbols, IDbCommand dc)
- {
- foreach (String paramName in ExtractParamNames(dc.CommandText))
- {
- AddInput(dc, paramName, symbols.GetValueOrDefault(paramName, null));
- }
- }
- public void CloseConnection()
- {
- if (CurrentTransaction != null)
- {
- CurrentTransaction.Rollback();
- }
- if (CurrentConnection != null)
- {
- CurrentConnection.Close();
- CurrentConnection = null;
- CurrentTransaction = null;
- }
- }
- public void Commit()
- {
- CurrentTransaction.Commit();
- CurrentTransaction = CurrentConnection.BeginTransaction();
- }
- public void Rollback()
- {
- CurrentTransaction.Rollback();
- CurrentTransaction = CurrentConnection.BeginTransaction();
- }
-
- public virtual String BuildUpdateCommand(String tableName, DbParameterAccessor[] updateAccessors, DbParameterAccessor[] selectAccessors)
- {
- if (updateAccessors.Length == 0)
- {
- throw new ApplicationException("must have at least one field to update. Have you forgotten = after the column name?");
- }
- var s = new StringBuilder("update ").Append(tableName).Append(" set ");
- for (var i = 0; i < updateAccessors.Length; i++)
- {
- if (i > 0) s.Append(", ");
- s.Append(BuildColumnName(updateAccessors[i].DbParameter.SourceColumn)).Append("=");
- s.Append(ParameterPrefix).Append(updateAccessors[i].DbParameter.ParameterName);
- }
- s.Append(" where ");
- for (var i = 0; i < selectAccessors.Length; i++)
- {
- if (i > 0) s.Append(" and ");
- s.Append(BuildColumnName(selectAccessors[i].DbParameter.SourceColumn)).Append("=");
- s.Append(ParameterPrefix).Append(selectAccessors[i].DbParameter.ParameterName);
- }
- return s.ToString();
- }
-
- public virtual string[] ExtractParamNames(string commandText)
- {
- //dotnet2 does not support sets, so a set is simmulated with a hashmap
- Dictionary parameters = new Dictionary();
- MatchCollection mc = ParamNameRegex.Matches(commandText);
- for (int i = 0; i < mc.Count; i++) parameters[mc[i].Groups[1].Value] = mc[i].Groups[1].Value;
- string[] arr = new string[parameters.Keys.Count];
- parameters.Keys.CopyTo(arr, 0);
- return arr;
- }
-
- public virtual int GetExceptionCode(Exception dbException)
- {
- if (dbException is System.Data.Common.DbException)
- {
- System.Console.WriteLine("DBEXCEPTION:" + ((System.Data.Common.DbException)dbException).ErrorCode);
- return ((System.Data.Common.DbException)dbException).ErrorCode;
- }
- else
- {
- System.Console.WriteLine("EXCEPTION:" + dbException.GetType().ToString());
- return 0;
- }
- }
-
- public virtual String BuildInsertCommand(String tableName, DbParameterAccessor[] accessors)
- {
- var sb = new StringBuilder("insert into ");
- sb.Append(tableName).Append("(");
- var separator = "";
- var values = new StringBuilder();
- foreach (var accessor in accessors)
- {
- sb.Append(separator);
- values.Append(separator);
- sb.Append(BuildColumnName(accessor.DbParameter.SourceColumn));
- values.Append(ParameterPrefix).Append(accessor.DbParameter.ParameterName);
- separator = ",";
- }
- sb.Append(") values (");
- sb.Append(values);
- sb.Append(")");
- return sb.ToString();
- }
-
- #endregion
-
- #region inherited methods from IDbEnvironment that have no default implementation
-
- protected abstract String GetConnectionString(String dataSource, String username, String password);
- protected abstract String GetConnectionString(String dataSource, String username, String password, String database);
- protected abstract Regex ParamNameRegex { get; }
- public abstract DbProviderFactory DbProviderFactory { get ; }
- public abstract Dictionary GetAllProcedureParameters(string procName);
- public abstract Dictionary GetAllColumns(string tableOrViewName);
-
- public abstract bool SupportsReturnOnInsert { get;}
- public abstract String IdentitySelectStatement(String tableName);
-#endregion
-
- protected virtual string BuildColumnName(string sourceColumnName) { return sourceColumnName; }
- }
-}
diff --git a/source/dbfit/environment/DbEnvironment.cs b/source/dbfit/environment/DbEnvironment.cs
deleted file mode 100644
index 0a98f2b0..00000000
--- a/source/dbfit/environment/DbEnvironment.cs
+++ /dev/null
@@ -1,170 +0,0 @@
-// Copyright © 2015 Syterra Software Inc. Includes work Copyright (C) Gojko Adzic 2006-2008 http://gojko.net
-// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.
-// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-using System;
-using System.Collections.Generic;
-using System.Data.Common;
-using System.Data;
-using fitSharp.Machine.Engine;
-
-namespace dbfit {
- ///
- /// IDbEnvironment provides a common interface for database-specific meta-data retrieval
- /// and operations. IDbEnvironment instances encapculate all database-specific functionality,
- /// so that DbFit fixtures can be database-neutral. IDbEnvironment instances are also
- /// responsible for transaction management.
- ///
- public interface IDbEnvironment {
- ///
- /// Retrieves an instance of DbProviderFactory class that can be used
- /// to create database-specific implementations of database parameters,
- /// data-set readers etc
- ///
- DbProviderFactory DbProviderFactory { get ; }
- ///
- /// A flag to signal whether the database supports output parameters on insert commands,
- /// or whether the auto-generated identity values have to be retrieved with a separate
- /// statement after insert.
- ///
- bool SupportsReturnOnInsert { get ;}
- ///
- /// If the database requires an additional statement to fetch auto-generated identity values passing the table name,
- /// this property is used as the select query to execute that statement.
- ///
- String IdentitySelectStatement(String tableName);
- ///
- /// Meta-data retrieval method that provides a list of parameters for a given stored procedure
- /// or function name. The name may contain a schema qualifier.
- ///
- /// name of the procedure or function to look up in the database
- /// a map of parameter names to DbParameterAccessor objects for procedure parameters
- Dictionary GetAllProcedureParameters(string procName);
-
- ///
- /// Meta-data retrieval method that provides a list of columns a given stored table
- /// or view. The name may contain a schema qualifier.
- ///
- /// name of the table or view to look up in the database
- /// a map of column names to DbParameterAccessor objects for table columns
-
- Dictionary GetAllColumns(string tableOrViewName);
- ///
- /// This method creates an insert command that will be used to populate new rows in a table
- ///
- /// table or view name to be used for inserting
- /// list of columns that will be used in the insert command
- /// Command string in the appropriate form, with parameter placeholders
- String BuildInsertCommand(String tableName, DbParameterAccessor[] accessors);
- ///
- /// This method should create and initialise a DbCommand object based on the current
- /// IDbEnvironment connection and transaction.
- ///
- /// Command text to execute
- /// Statement type
- /// initialised DbCommand object
- IDbCommand CreateCommand(string statement, CommandType commandType);
- ///
- /// Closes the current connection and rolls back any active transactions. The transactions
- /// are automatically rolled back to make tests repeatable.
- ///
- void CloseConnection();
- ///
- /// Connects to the database using a default database for the user
- ///
- /// Host (optionally port), machine name or any other data source identifier
- void Connect(String dataSource, String username, String password);
-
- ///
- /// Connects to the database using a specified database for the user
- ///
- /// Host (optionally port), machine name or any other data source identifier
- /// default database after connection
- void Connect(String dataSource, String username, String password, String database);
-
- ///
- /// Connects using a database-specific connection string. This allows users to specify
- /// parameters that would not be used otherwise (i.e. windows integrated security)
- ///
- /// full ADO.NET connection string
- void Connect(String connectionString);
-
- ///
- /// Load database properties from a file and connect.
- /// The connection properties file is a plain text file, containing key/value pairs separarted by the equals symbol (=). Lines starting with a hash (#) are ignored. Use the following keys (they care case-sensitive):
- ///
- /// 1. service -- service name. In the previous example, it was LAPTOP\SQLEXPRESS.
- /// 2. username -- username to connect to the database. In the previous example, it was FitNesseUser.
- /// 3. password -- password to connect to the database. In the previous example, it was Password.
- /// 4. database -- optional fourth argument, allowing you to choose the active database. In the previous example, it was TestDB.
- /// 5. connection-string -- alternative to the four previous parameters, this allows you to specify the full connection string. This parameter should not be mixed with any of the four other keys. Use either the full string or specify individual properties.
- ///
- /// Here is an example:
- ///
- /// # DBFit connection properties file
- /// #
- /// #1) Either specify full connection string
- /// #connection-string=
- /// #
- /// #2) OR specify service, username and password as separate properties
- /// service=localhost
- /// username=root
- /// password=
- /// #optionally specify a database name
- /// database=dbfit
- ///
- ///
- void ConnectUsingFile(String connectionPropertiesFile);
-
- void ConnectUsingConfig(string connectionName);
-
- ///
- /// Connects to the database using a specified database for the user witout a transaction
- ///
- /// Host (optionally port), machine name or any other data source identifier
- /// default database after connection
- void ConnectNoTransaction(String dataSource, String username, String password, String database);
-
- ///
- /// bind any fixture symbols that match command parameters to this command.
- /// symbols that have no matching parameters are ignored.
- ///
- ///
- void BindFixtureSymbols(Symbols symbols, IDbCommand dc);
-
- ///
- /// Commit current transaction
- ///
- void Commit();
-
- ///
- /// Rollback current transaction
- ///
- void Rollback();
- ///
- /// Retrieve an exception code from a database exception. This method should perform
- /// any required conversion between a .NET exception and the real database error code.
- ///
- int GetExceptionCode(Exception ex);
-
- ///
- /// Utility method that creates an update command statement
- ///
- /// table or view being updated
- /// fields that are being modified
- /// fields used for selecting affected records
- ///
- String BuildUpdateCommand(String tableName, DbParameterAccessor[] updateAccessors,
- DbParameterAccessor[] selectAccessors);
- ///
- /// Accessor for the current database connection, used by DBFit Fixtures
- ///
- IDbConnection CurrentConnection { get; }
- ///
- /// Accessor for the current database transaction, used by DBFit Fixtures
- ///
- IDbTransaction CurrentTransaction { get; }
-
- }
-}
\ No newline at end of file
diff --git a/source/dbfit/environment/DbEnvironmentFactory.cs b/source/dbfit/environment/DbEnvironmentFactory.cs
deleted file mode 100644
index ef7831ed..00000000
--- a/source/dbfit/environment/DbEnvironmentFactory.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-/// Copyright (C) Gojko Adzic 2006-2008 http://gojko.net
-/// Released under GNU GPL 2.0
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace dbfit {
- ///
- /// Static singleton holder for an IDbEnvironment instance that is used
- /// as the "current" environment in standalone mode. This class can also
- /// be used by 3rd party fixtures to access DbFit features or execute
- /// statements in the same transaction.
- ///
- public class DbEnvironmentFactory {
- private static IDbEnvironment instance;
- public static IDbEnvironment DefaultEnvironment
- {
- get { return instance; }
- set { instance=value; }
- }
- }
-}
diff --git a/source/dbfit/fixture/Clean.cs b/source/dbfit/fixture/Clean.cs
deleted file mode 100644
index da77fccb..00000000
--- a/source/dbfit/fixture/Clean.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-/// Copyright (C) Gojko Adzic 2006-2008 http://gojko.net
-/// Released under GNU GPL 2.0
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-using System.Text;
-
-using fit;
-
-
-namespace dbfit.fixture {
- ///
- /// Deprecated fixture that can be used to clean up the database. Kept only for
- /// legacy compatibility. Use Execute fixture with a Delete command instead of this.
- ///
- public class Clean:fit.ColumnFixture {
-
- private IDbEnvironment environment;
- public Clean(IDbEnvironment environment) {
- this.environment = environment;
- }
- public Clean()
- {
- this.environment = DbEnvironmentFactory.DefaultEnvironment;
- }
- public String table;
- public String columnName;
- public Decimal[] ids;
- public String[] keys;
- public string where=null;
- private string getIDCSV()
- {
- StringBuilder sb = new StringBuilder();
- String comma = "";
- foreach (decimal x in ids)
- {
- sb.Append(comma);
- sb.Append(x.ToString());
- comma = ", ";
- }
- return sb.ToString();
- }
- private string getKeyCSV()
- {
- StringBuilder sb = new StringBuilder();
- String comma = "";
- foreach (String x in keys)
- {
- sb.Append(comma);
- sb.Append("'");
- sb.Append(x.ToString());
- sb.Append("'");
- comma = ", ";
- }
- return sb.ToString();
- }
-
- private bool hadRowOperation=false;
- public bool clean() {
- var command = environment.CreateCommand(
- "Delete from " + table +(where!=null?" where "+where:""), CommandType.Text);
- command.ExecuteNonQuery();
- return true;
- }
- public bool DeleteRowsForIDs()
- {
- var command = environment.CreateCommand(
- "Delete from " + table + " where "+columnName +" in ("
- + getIDCSV()+") "+(where != null ? " and " + where : ""), CommandType.Text);
- command.ExecuteNonQuery();
- hadRowOperation=true;
- return true;
- }
- public bool DeleteRowsForKeys()
- {
- var command = environment.CreateCommand(
- "Delete from " + table + " where " + columnName + " in ("
- + getKeyCSV() + ") " + (where != null ? " and " + where : ""), CommandType.Text);
- command.ExecuteNonQuery();
- hadRowOperation=true;
- return true;
- }
- public override void DoRow(Parse row) {
- hadRowOperation = false;
- base.DoRow(row);
- if (!hadRowOperation) {
- clean();
- }
- }
- }
-}
\ No newline at end of file
diff --git a/source/dbfit/fixture/CompareStoredQueries.cs b/source/dbfit/fixture/CompareStoredQueries.cs
deleted file mode 100644
index 15a016fb..00000000
--- a/source/dbfit/fixture/CompareStoredQueries.cs
+++ /dev/null
@@ -1,227 +0,0 @@
-/// Copyright (C) Gojko Adzic 2006-2008 http://gojko.net
-/// Released under GNU GPL 2.0
-using System;
-using System.Collections.Generic;
-using fit;
-using System.Data;
-using dbfit.util;
-using fitSharp.Fit.Model;
-using fitSharp.Machine.Model;
-
-namespace dbfit.fixture
-{
- ///
- /// This fixture compares two DataTable objects and prints out any unmatched rows.
- /// DataTables are read from Fixture symbols.
- ///
- public class CompareStoredQueries:fit.Fixture
- {
- private IDbEnvironment dbEnvironment;
- private String symbol1;
- private String symbol2;
- private DataTable dt1;
- private DataTable dt2;
- private String[] columnNames;
- private bool[] keyProperties;
- ///
- /// Constructor that will use the default environment (from DbEnvironmentFactory) and
- /// read the DataTable objects to compare from symbols contained in the first
- /// two fixture arguments. Intended for use in standalone mode.
- ///
- public CompareStoredQueries()
- {
- dbEnvironment = DbEnvironmentFactory.DefaultEnvironment;
- }
- ///
- /// Constructor that allows the caller to pass an IDbEnvironment instance and two symbol names
- /// that will be used to retrieve DataTable objects for comparison. Intended for use in flow mode.
- ///
- ///
- /// Symbol name for the fixture symbol containing the first DataTable
- /// Symbol name for the fixture symbol containing the second DataTable
- public CompareStoredQueries(IDbEnvironment environment, String symbol1, String symbol2)
- {
- this.dbEnvironment = environment;
- this.symbol1 = symbol1;
- this.symbol2 = symbol2;
- }
- private DataTable GetDataTable(String symbolName){
- Object o=Symbols.GetValueOrDefault(symbolName, null);
- if (o==null) throw new ApplicationException("Cannot load a stored query from "+symbolName+ " - is is empty");
- if (o.GetType().Equals(typeof(DataTable))) return (DataTable) o;
- throw new ApplicationException("Cannot load stored query from "+symbolName
- + " - object type is "+o.GetType().Name);
- }
- private void InitialiseDataTables()
- {
- if (symbol1 == null || symbol2 == null)
- {
- if (Args.Length < 2)
- throw new ApplicationException("No symbols specified to CompareStoreQueries constructor or argument list");
- symbol1 = Args[0];
- symbol2 = Args[1];
- }
- if (symbol1.StartsWith("<<")) symbol1 = symbol1.Substring(2);
- if (symbol2.StartsWith("<<")) symbol2 = symbol2.Substring(2);
- // tables will be modified during comparison, so better to clone
- dt1 = GetDataTable(symbol1).Copy();
- dt2 = GetDataTable(symbol2).Copy();
- }
- private void LoadRowStructure(Parse headerRow)
- {
- Parse headerCell = headerRow.Parts;
- int colNum = headerRow.Parts.Size;
- columnNames = new String[colNum];
- keyProperties = new bool[colNum];
- for (int i = 0; i < colNum; i++)
- {
- String currentName = headerCell.Text;
- if (currentName == null) throw new ApplicationException("Column " + i + " does not have a name");
- currentName = currentName.Trim();
- if (currentName.Length == 0) throw new ApplicationException("Column " + i + " does not have a name");
- columnNames[i] = NameNormaliser.NormaliseName(currentName);
- keyProperties[i] = !currentName.EndsWith("?");
- headerCell = headerCell.More;
- }
- }
- public override void DoTable(Parse table)
- {
- InitialiseDataTables();
- Parse lastRow=table.Parts.More;
- if (lastRow==null){
- throw new ApplicationException("Query structure missing from second row");
- }
- LoadRowStructure(lastRow);
- lastRow=ProcessDataTable(dt1,dt2, lastRow, symbol2);
-
- foreach (DataRow dr in dt2.Rows){
- lastRow=AddRow(lastRow, dr, true, " missing from "+symbol1);
- }
- }
-
- private String GetStringValue(DataRow dr, String colName)
- {
- Object o = dr[colName];
- if (o == null) return "null";
- return o.ToString();
- }
-
- private Parse AddRow(Parse lastRow, DataRow dr, bool markAsError, String desc)
- {
- Parse newRow = new Parse("tr", null, null, null);
- lastRow.More = newRow;
- lastRow = newRow;
- try
- {
- Parse firstCell = new Parse("td",
- GetStringValue(dr, columnNames[0]), null, null);
- newRow.Parts = firstCell;
- if (markAsError)
- {
- firstCell.AddToBody(Fixture.Gray(desc));
- this.Wrong(firstCell);
- }
- for (int i = 1; i < columnNames.Length; i++)
- {
- Parse nextCell = new Parse("td",
- GetStringValue(dr, columnNames[i]), null, null);
- firstCell.More = nextCell;
- firstCell = nextCell;
- }
- }
- catch (Exception e)
- {
- this.Exception(newRow, e);
- }
- return lastRow;
- }
- private Parse addRow(Parse lastRow, DataRow dr, DataRow dr2)
- {
- Parse newRow = new Parse("tr", null, null, null);
- lastRow.More = newRow;
- lastRow = newRow;
- try
- {
- String lval = GetStringValue(dr, columnNames[0]);
- String rval = GetStringValue(dr2, columnNames[0]);
- Parse firstCell = new Parse("td", lval, null, null);
- newRow.Parts = firstCell;
- if (!lval.Equals(rval))
- {
- Wrong(firstCell, rval);
- }
- else
- {
- Right(firstCell);
- }
- for (int i = 1; i < columnNames.Length; i++)
- {
- lval = GetStringValue(dr, columnNames[i]);
- rval = GetStringValue(dr2, columnNames[i]);
- Parse nextCell = new Parse("td",
- lval, null, null);
- firstCell.More = nextCell;
- firstCell = nextCell;
- if (!lval.Equals(rval))
- {
- Wrong(firstCell, rval);
- }
- else
- {
- Right(firstCell);
- }
- }
- }
- catch (Exception e)
- {
- Exception(newRow, e);
- }
- return lastRow;
- }
- private bool IsMatch(DataRow dr, IDictionary matchingMask)
- {
- foreach (String key in matchingMask.Keys){
- object val = matchingMask[key];
- object drval = dr[key];
- if (val == null){
- if (drval!=null) return false;
- }
- else {
- if (!val.Equals(drval)) return false;
- }
- }
- return true;
- }
- private DataRow FindMatching(DataTable t, IDictionary matchingMask)
- {
- foreach (DataRow dr in t.Rows){
- if (IsMatch(dr,matchingMask)) return dr;
- }
- return null;
- }
- private Parse ProcessDataTable(DataTable t1, DataTable t2, Parse lastScreenRow, String queryName)
- {
-
- foreach (DataRow dr in t1.Rows)
- {
- IDictionary matchingMask = new Dictionary();
- for (int i = 0; i < keyProperties.Length; i++)
- {
- if (keyProperties[i])
- matchingMask[columnNames[i]] = dr[columnNames[i]];
- }
- DataRow dr2 = FindMatching(t2, matchingMask);
- if (dr2 != null)
- {
- lastScreenRow = addRow(lastScreenRow, dr, dr2);
- t2.Rows.Remove(dr2);
- }
- else
- {
- lastScreenRow = AddRow(lastScreenRow, dr, true, " missing from " + queryName);
- }
- }
- return lastScreenRow;
- }
- }
-}
diff --git a/source/dbfit/fixture/CompareStoredQueriesHideMatchingRows.cs b/source/dbfit/fixture/CompareStoredQueriesHideMatchingRows.cs
deleted file mode 100644
index f158705c..00000000
--- a/source/dbfit/fixture/CompareStoredQueriesHideMatchingRows.cs
+++ /dev/null
@@ -1,227 +0,0 @@
-/// Copyright (C) Gojko Adzic 2006-2008 http://gojko.net
-/// Released under GNU GPL 2.0
-using System;
-using System.Collections.Generic;
-using fit;
-using System.Data;
-using dbfit.util;
-using fitSharp.Fit.Model;
-using fitSharp.Machine.Model;
-
-namespace dbfit.fixture
-{
- ///
- /// This fixture compares two DataTable objects and prints out any unmatched rows.
- /// DataTables are read from Fixture symbols.
- ///
- public class CompareStoredQueriesHideMatchingRows:fit.Fixture
- {
- private IDbEnvironment dbEnvironment;
- private String symbol1;
- private String symbol2;
- private DataTable dt1;
- private DataTable dt2;
- private String[] columnNames;
- private bool[] keyProperties;
- ///
- /// Constructor that will use the default environment (from DbEnvironmentFactory) and
- /// read the DataTable objects to compare from symbols contained in the first
- /// two fixture arguments. Intended for use in standalone mode.
- ///
- public CompareStoredQueriesHideMatchingRows()
- {
- dbEnvironment = DbEnvironmentFactory.DefaultEnvironment;
- }
- ///
- /// Constructor that allows the caller to pass an IDbEnvironment instance and two symbol names
- /// that will be used to retrieve DataTable objects for comparison. Intended for use in flow mode.
- ///
- ///
- /// Symbol name for the fixture symbol containing the first DataTable
- /// Symbol name for the fixture symbol containing the second DataTable
- public CompareStoredQueriesHideMatchingRows(IDbEnvironment environment, String symbol1, String symbol2)
- {
- this.dbEnvironment = environment;
- this.symbol1 = symbol1;
- this.symbol2 = symbol2;
- }
- private DataTable GetDataTable(String symbolName){
- Object o=Symbols.GetValueOrDefault(symbolName, null);
- if (o==null) throw new ApplicationException("Cannot load a stored query from "+symbolName+ " - is is empty");
- if (o.GetType().Equals(typeof(DataTable))) return (DataTable) o;
- throw new ApplicationException("Cannot load stored query from "+symbolName
- + " - object type is "+o.GetType().Name);
- }
- private void InitialiseDataTables()
- {
- if (symbol1 == null || symbol2 == null)
- {
- if (Args.Length < 2)
- throw new ApplicationException("No symbols specified to CompareStoreQueries constructor or argument list");
- symbol1 = Args[0];
- symbol2 = Args[1];
- }
- if (symbol1.StartsWith("<<")) symbol1 = symbol1.Substring(2);
- if (symbol2.StartsWith("<<")) symbol2 = symbol2.Substring(2);
- // tables will be modified during comparison, so better to clone
- dt1 = GetDataTable(symbol1).Copy();
- dt2 = GetDataTable(symbol2).Copy();
- }
- private void LoadRowStructure(Parse headerRow)
- {
- Parse headerCell = headerRow.Parts;
- int colNum = headerRow.Parts.Size;
- columnNames = new String[colNum];
- keyProperties = new bool[colNum];
- for (int i = 0; i < colNum; i++)
- {
- String currentName = headerCell.Text;
- if (currentName == null) throw new ApplicationException("Column " + i + " does not have a name");
- currentName = currentName.Trim();
- if (currentName.Length == 0) throw new ApplicationException("Column " + i + " does not have a name");
- columnNames[i] = NameNormaliser.NormaliseName(currentName);
- keyProperties[i] = !currentName.EndsWith("?");
- headerCell = headerCell.More;
- }
- }
- public override void DoTable(Parse table)
- {
- InitialiseDataTables();
- Parse lastRow=table.Parts.More;
- if (lastRow==null){
- throw new ApplicationException("Query structure missing from second row");
- }
- LoadRowStructure(lastRow);
- lastRow=ProcessDataTable(dt1,dt2, lastRow, symbol2);
-
- foreach (DataRow dr in dt2.Rows){
- lastRow=AddRow(lastRow, dr, true, " missing from "+symbol1);
- }
- }
-
- private String GetStringValue(DataRow dr, String colName)
- {
- Object o = dr[colName];
- if (o == null) return "null";
- return o.ToString();
- }
-
- private Parse AddRow(Parse lastRow, DataRow dr, bool markAsError, String desc)
- {
- Parse newRow = new Parse("tr", null, null, null);
- lastRow.More = newRow;
- lastRow = newRow;
- try
- {
- Parse firstCell = new Parse("td",
- GetStringValue(dr, columnNames[0]), null, null);
- newRow.Parts = firstCell;
- if (markAsError)
- {
- firstCell.AddToBody(Fixture.Gray(desc));
- this.Wrong(firstCell);
- }
- for (int i = 1; i < columnNames.Length; i++)
- {
- Parse nextCell = new Parse("td",
- GetStringValue(dr, columnNames[i]), null, null);
- firstCell.More = nextCell;
- firstCell = nextCell;
- }
- }
- catch (Exception e)
- {
- this.Exception(newRow, e);
- }
- return lastRow;
- }
- private Parse addRow(Parse lastRow, DataRow dr, DataRow dr2)
- {
- Parse newRow = new Parse("tr", null, null, null);
- lastRow.More = newRow;
- lastRow = newRow;
- try
- {
- String lval = GetStringValue(dr, columnNames[0]);
- String rval = GetStringValue(dr2, columnNames[0]);
- Parse firstCell = new Parse("td", lval, null, null);
- newRow.Parts = firstCell;
- if (!lval.Equals(rval))
- {
- Wrong(firstCell, rval);
- }
- else
- {
- Right(firstCell);
- }
- for (int i = 1; i < columnNames.Length; i++)
- {
- lval = GetStringValue(dr, columnNames[i]);
- rval = GetStringValue(dr2, columnNames[i]);
- Parse nextCell = new Parse("td",
- lval, null, null);
- firstCell.More = nextCell;
- firstCell = nextCell;
- if (!lval.Equals(rval))
- {
- Wrong(firstCell, rval);
- }
- else
- {
- Right(firstCell);
- }
- }
- }
- catch (Exception e)
- {
- Exception(newRow, e);
- }
- return lastRow;
- }
- private bool IsMatch(DataRow dr, IDictionary matchingMask)
- {
- foreach (String key in matchingMask.Keys){
- object val = matchingMask[key];
- object drval = dr[key];
- if (val == null){
- if (drval!=null) return false;
- }
- else {
- if (!val.Equals(drval)) return false;
- }
- }
- return true;
- }
- private DataRow FindMatching(DataTable t, IDictionary matchingMask)
- {
- foreach (DataRow dr in t.Rows){
- if (IsMatch(dr,matchingMask)) return dr;
- }
- return null;
- }
- private Parse ProcessDataTable(DataTable t1, DataTable t2, Parse lastScreenRow, String queryName)
- {
-
- foreach (DataRow dr in t1.Rows)
- {
- IDictionary matchingMask = new Dictionary();
- for (int i = 0; i < keyProperties.Length; i++)
- {
- if (keyProperties[i])
- matchingMask[columnNames[i]] = dr[columnNames[i]];
- }
- DataRow dr2 = FindMatching(t2, matchingMask);
- if (dr2 != null)
- {
- //lastScreenRow = addRow(lastScreenRow, dr, dr2);
- t2.Rows.Remove(dr2);
- }
- else
- {
- lastScreenRow = AddRow(lastScreenRow, dr, true, " missing from " + queryName);
- }
- }
- return lastScreenRow;
- }
- }
-}
diff --git a/source/dbfit/fixture/DatabaseEnvironment.cs b/source/dbfit/fixture/DatabaseEnvironment.cs
deleted file mode 100644
index 7b9cc4a0..00000000
--- a/source/dbfit/fixture/DatabaseEnvironment.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright © 2010 Syterra Software Inc. Includes work Copyright (C) Gojko Adzic 2006-2008 http://gojko.net
-// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.
-// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-using System;
-using fitSharp.Fit.Model;
-using fitSharp.Machine.Engine;
-using fitSharp.Machine.Model;
-
-namespace dbfit.fixture
-{
- ///
- /// Utility fixture that provides database control features in standalone mode. This fixture
- /// should be used to connect/disconnect and manipulate transactions when the flow mode
- /// cannot be used. It is also used to control dbfit options and advanced features.
- ///
- /// If it has a fixture argument, that argument is used to initialise a new IDbEnvironment object.
- /// The argument value should be the type of required IDbInstance implementation, like
- /// ORACLE, SQLSERVER, SQLSERVER2000 or DB2. That object is then stored for later use in the
- /// DbEnvironmentFactory singleton.
- ///
- /// If there are no fixture arguments, then the last previously initialised
- /// IDbEnvironment object is used.
- ///
- ///
- public class DatabaseEnvironment : fitlibrary.SequenceFixture
- {
- public DatabaseEnvironment(){
- mySystemUnderTest=DbEnvironmentFactory.DefaultEnvironment;
- }
- public override void DoTable(fit.Parse theTable)
- {
- if (Args.Length>0){
- String requestedEnv=Args[0].ToUpper().Trim();
- IDbEnvironment env;
- if ("ORACLE".Equals(requestedEnv))
- env = MakeEnvironment("dbfit.OracleEnvironment");
- else if ("SQLSERVER".Equals(requestedEnv))
- env = MakeEnvironment("dbfit.SqlServerEnvironment");
- else if ("SQLSERVER2000".Equals(requestedEnv))
- env = MakeEnvironment("dbfit.SqlServer2000Environment");
- else if ("SYBASE".Equals(requestedEnv))
- env = MakeEnvironment("dbfit.SybaseEnvironment");
- else if ("MYSQL".Equals(requestedEnv))
- env = MakeEnvironment("dbfit.MySqlEnvironment");
- /* else if ("DB2".Equals(requestedEnv))
- env = Processor.Create("DB2Environment", new TreeList()); */
- else
- throw new ApplicationException("DB Environment not supported " + requestedEnv);
- DbEnvironmentFactory.DefaultEnvironment=env;
- mySystemUnderTest=DbEnvironmentFactory.DefaultEnvironment;
- }
- base.DoTable(theTable);
- }
-
- private IDbEnvironment MakeEnvironment(string name) {
- return Processor.Create(name, new CellTree()).GetValue();
- }
-
- ///
- /// set the value of DbFit options. See dbfit.util.options for more information
- ///
- /// option name
- /// option vaue
- public void SetOption(String option, String value)
- {
- util.Options.SetOption(Processor, option, value);
- }
- }
-}
diff --git a/source/dbfit/fixture/DatabaseTest.cs b/source/dbfit/fixture/DatabaseTest.cs
deleted file mode 100644
index ba3f3062..00000000
--- a/source/dbfit/fixture/DatabaseTest.cs
+++ /dev/null
@@ -1,213 +0,0 @@
-// Copyright � 2015 Syterra Software Inc. Includes work Copyright (C) Gojko Adzic 2006-2008 http://gojko.net
-// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.
-// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-using System;
-using System.Data;
-using System.Data.Common;
-using dbfit.fixture;
-using dbfit.util;
-using fit;
-
-using fitlibrary;
-using fitSharp.Machine.Engine;
-
-namespace dbfit
-{
- public class DatabaseTest : SequenceFixture
- {
- protected IDbEnvironment environment;
-
- public void SetUp() {
- util.Options.reset();
- }
-
- public void TearDown() {
- environment.CloseConnection();
- }
-
- public DatabaseTest(IDbEnvironment environment)
- {
- this.environment = environment;
- }
-
- public void Connect(String dataSource, String username, String password, String database)
- {
- environment.Connect(dataSource, username, password, database);
- }
-
- public void Connect(String dataSource, String username, String password)
- {
- environment.Connect(dataSource, username, password);
- }
-
- public void Connect(String connectionString)
- {
- environment.Connect(connectionString);
- }
-
- public void ConnectUsingFile(String path)
- {
- environment.ConnectUsingFile(path);
- }
-
- public void ConnectUsingConfig(string connectionName) {
- environment.ConnectUsingConfig(connectionName);
- }
-
- public void Close()
- {
- environment.CloseConnection();
- }
-
- public void SetParameter(String name, object value)
- {
- fixture.SetParameter.SetParameterValue(Symbols, name, value);
- }
-
- public Fixture SetTableParameter(String name, String type)
- {
- return new SetTableParameter(environment, Symbols, name, type);
- }
-
- public void ClearParameters()
- {
- Symbols.Clear();
- }
-
- public Fixture Query(String query)
- {
- return new Query(GetDataTable(Symbols, query, environment), false);
- }
-
- public Fixture Query(String query, int resultSet)
- {
- return new Query(GetDataTable(Symbols, query, environment, resultSet), false);
- }
-
- public Fixture Query(DataTable queryTable)
- {
- return new Query(queryTable, false);
- }
-
- public Fixture Update(String table)
- {
- return new Update(environment, table);
- }
-
- public Fixture OrderedQuery(String query)
- {
- return new Query(GetDataTable(Symbols, query, environment), true);
- }
-
- public Fixture Execute(String statement)
- {
- return new Execute(environment, statement);
- }
-
- public Fixture ExecuteDDL(String statement)
- {
- return new ExecuteDDL(environment, statement);
- }
-
- public Fixture Insert(String table)
- {
- return new Insert(environment, table);
- }
-
- public Fixture ExecuteProcedure(String procedure)
- {
- return new ExecuteProcedure(environment, procedure);
- }
-
- public Fixture ExecuteProcedureExpectException(String procedure)
- {
- return new ExecuteProcedure(environment, procedure, true);
- }
-
- public Fixture ExecuteProcedureExpectException(String procedure, int errorCode)
- {
- return new ExecuteProcedure(environment, procedure, errorCode);
- }
-
- public void Commit()
- {
- environment.Commit();
- }
-
- public void Rollback()
- {
- environment.Rollback();
- }
-
- public Fixture QueryStats()
- {
- return new QueryStats(environment);
- }
-
- public Fixture Clean()
- {
- return new Clean(environment);
- }
-
- public Fixture InspectProcedure(String procedure)
- {
- return new Inspect(environment, Inspect.MODE_PROCEDURE, procedure);
- }
-
- public Fixture InspectTable(String table)
- {
- return new Inspect(environment, Inspect.MODE_TABLE, table);
- }
-
- public Fixture InspectView(String view)
- {
- return new Inspect(environment, Inspect.MODE_TABLE, view);
- }
-
- public Fixture InspectQuery(String query)
- {
- return new Inspect(environment, Inspect.MODE_QUERY, query);
- }
-
- public Fixture StoreQuery(String query, String symbolName)
- {
- return new StoreQuery(environment, query, symbolName);
- }
-
- public Fixture CompareStoredQueries(String symbol1, String symbol2)
- {
- return new CompareStoredQueries(environment, symbol1, symbol2);
- }
-
- public Fixture CompareStoredQueriesHideMatchingRows(String symbol1, String symbol2)
- {
- return new CompareStoredQueriesHideMatchingRows(environment, symbol1, symbol2);
- }
-
- public void SetOption(String option, String value)
- {
- util.Options.SetOption(Processor, option, value);
- }
-
- public static DataTable GetDataTable(Symbols symbols, String query, IDbEnvironment environment)
- {
- return GetDataTable(symbols, query, environment, 1);
- }
-
- public static DataTable GetDataTable(Symbols symbols, String query,IDbEnvironment environment, int rsNo)
- {
- var dc = environment.CreateCommand(query, CommandType.Text);
- if (Options.ShouldBindSymbols())
- environment.BindFixtureSymbols(symbols, dc);
-
- var oap = environment.DbProviderFactory.CreateDataAdapter();
- oap.SelectCommand = (DbCommand)dc;
- var ds = new DataSet();
- oap.Fill(ds);
- dc.Dispose();
- return ds.Tables[rsNo - 1];
- }
- }
-}
diff --git a/source/dbfit/fixture/Execute.cs b/source/dbfit/fixture/Execute.cs
deleted file mode 100644
index 6e93b873..00000000
--- a/source/dbfit/fixture/Execute.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using fit;
-using System.Data;
-using System.Data.Common;
-namespace dbfit.fixture
-{
- public class Execute:fit.Fixture
- {
- private IDbEnvironment environment;
- private String statement;
- public Execute()
- {
- environment = DbEnvironmentFactory.DefaultEnvironment;
- }
- public Execute(IDbEnvironment environment, String statement)
- {
- this.environment = environment;
- this.statement = statement;
- }
- public override void DoRows(Parse rows)
- {
- if (String.IsNullOrEmpty(statement))
- statement = Args[0];
- using (var dc = environment.CreateCommand(statement, CommandType.Text))
- {
- if (dbfit.util.Options.ShouldBindSymbols())
- environment.BindFixtureSymbols(Symbols, dc);
- dc.ExecuteNonQuery();
- }
- }
- }
-}
diff --git a/source/dbfit/fixture/ExecuteDDL.cs b/source/dbfit/fixture/ExecuteDDL.cs
deleted file mode 100644
index 77397a19..00000000
--- a/source/dbfit/fixture/ExecuteDDL.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using fit;
-using System.Data;
-using System.Data.Common;
-namespace dbfit.fixture
-{
- public class ExecuteDDL:fit.Fixture
- {
- private IDbEnvironment environment;
- private String statement;
- public ExecuteDDL()
- {
- environment = DbEnvironmentFactory.DefaultEnvironment;
- }
- public ExecuteDDL(IDbEnvironment environment, String statement)
- {
- this.environment = environment;
- this.statement = statement;
- }
- public override void DoRows(Parse rows)
- {
- if (String.IsNullOrEmpty(statement))
- statement = Args[0];
- using (var dc = environment.CreateCommand(statement, CommandType.Text))
- {
- dc.ExecuteNonQuery();
- }
- }
- }
-}
diff --git a/source/dbfit/fixture/ExecuteProcedure.cs b/source/dbfit/fixture/ExecuteProcedure.cs
deleted file mode 100644
index 84aaf210..00000000
--- a/source/dbfit/fixture/ExecuteProcedure.cs
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright © 2012 Syterra Software Inc. Includes work Copyright (C) Gojko Adzic 2006-2008 http://gojko.net
-// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.
-// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-
-using fit;
-using dbfit.util;
-using fitSharp.Fit.Operators;
-using fitSharp.Fit.Service;
-using fitSharp.Machine.Engine;
-
-namespace dbfit.fixture
-{
- public class ExecuteProcedure : ColumnFixture, MemberQueryable
- {
- private readonly IDbEnvironment dbEnvironment;
- private readonly bool expectException;
- private readonly List accessors = new List();
- private IDbCommand command;
- private String procedureName;
- private int? errorCode;
- private Parse currentRow;
- private ColumnAccessors columnAccessors;
-
- public ExecuteProcedure()
- {
- dbEnvironment = DbEnvironmentFactory.DefaultEnvironment;
- }
- public ExecuteProcedure(IDbEnvironment dbEnvironment, String procedureName, bool expectException)
- {
- this.procedureName = procedureName;
- this.dbEnvironment = dbEnvironment;
- this.expectException = expectException;
- errorCode = null;
- }
- public ExecuteProcedure(IDbEnvironment dbEnvironment, String procedureName, int errorCode)
- {
- this.procedureName = procedureName;
- this.dbEnvironment = dbEnvironment;
- expectException = true;
- this.errorCode = errorCode;
- }
- public ExecuteProcedure(IDbEnvironment dbEnvironment, String procedureName)
- : this(dbEnvironment, procedureName, false)
- {
- }
- public override void DoRows(Parse rows)
- {
- if (String.IsNullOrEmpty(procedureName)) procedureName = Args[0];
- if (rows != null)
- {
- InitParameters(rows.Parts);
- InitCommand();
- base.DoRows(rows);
- }
- else
- {
- columnAccessors = new ColumnAccessors();
- InitCommand();
- command.ExecuteNonQuery();
- }
- }
-
- public override void DoRow(Parse row) {
- currentRow = row;
- base.DoRow(row);
- }
-
- public override void DoCells(Parse cells) {
- ProcessCells(cells, b => !b.IsCheck);
- ProcessCells(cells, b => b.IsCheck);
- }
-
- private void ProcessCells(Parse cells, Func bindingFilter) {
- int i = 0;
- for (Parse cell = cells; cell != null && i < ColumnBindings.Length; cell = cell.More, i++) {
- if (!bindingFilter(ColumnBindings[i])) continue;
- try {
- DoCell(cell, i);
- }
- catch (Exception e) {
- TestStatus.MarkException(cells, e);
- }
- }
- }
-
- public static DbParameterAccessor[] SortAccessors(IEnumerable accessors)
- {
- var sortedAccessors = new List(accessors);
- for (int i = 0; i < sortedAccessors.Count - 1; i++)
- for (int j = i + 1; j < sortedAccessors.Count; j++)
- {
- if (sortedAccessors[i].Position <= sortedAccessors[j].Position) continue;
- DbParameterAccessor x = sortedAccessors[i];
- sortedAccessors[i] = sortedAccessors[j];
- sortedAccessors[j] = x;
- }
- return sortedAccessors.ToArray();
- }
- private void InitCommand()
- {
- command = dbEnvironment.CreateCommand(procedureName, CommandType.StoredProcedure);
- DbParameterAccessor[] sortedAccessors = SortAccessors(accessors);
-
- foreach (DbParameterAccessor accessor in sortedAccessors)
- {
- // in/out params can cause the same parameter to be added twice,
- // check to avoid that
- if (!command.Parameters.Contains(accessor.DbParameter))
- command.Parameters.Add(accessor.DbParameter);
- }
- }
-
- public override void Execute() {
- if (expectException) {
- try {
- command.ExecuteNonQuery();
- Wrong(currentRow);
- }
- catch (Exception e) {
- currentRow.Parts.Last.More = new Parse("td", Gray(e.ToString()), null, null);
- if (errorCode.HasValue) {
- if (dbEnvironment.GetExceptionCode(e) == errorCode)
- Right(currentRow);
- else
- Wrong(currentRow);
- }
- else
- Right(currentRow);
- }
- }
- else {
- command.ExecuteNonQuery();
- }
- }
-
- private void InitParameters(Parse headerCells)
- {
- Dictionary allParams =
- dbEnvironment.GetAllProcedureParameters(procedureName);
- columnAccessors = new ColumnAccessors();
- for (int i = 0; headerCells != null; i++, headerCells = headerCells.More)
- {
- String paramName = NameNormaliser.NormaliseName(headerCells.Text);
- try
- {
- DbParameterAccessor accessor = DbParameterAccessor.CloneWithSameParameter(allParams[paramName]);
- accessor.IsBoundToCheckOperation = BindingFactory.CheckIsImpliedBy(headerCells.Text);
- // sql server quirk. if output parameter is used in an input column, then
- // the param should be remapped to IN/OUT
- if ((!accessor.IsBoundToCheckOperation) &&
- accessor.DbParameter.Direction == ParameterDirection.Output)
- accessor.DbParameter.Direction = ParameterDirection.InputOutput;
- columnAccessors.Assign(paramName, accessor);
- accessors.Add(accessor);
- }
- catch (KeyNotFoundException)
- {
- Wrong(headerCells);
- throw new ApplicationException("Cannot find parameter " + paramName);
- }
- }
- }
-
- public RuntimeMember Find(MemberSpecification specification) {
- return columnAccessors.Find(specification, accessor => specification.MatchesIdentifierName(accessor.Key));
- }
- }
-}
diff --git a/source/dbfit/fixture/Insert.cs b/source/dbfit/fixture/Insert.cs
deleted file mode 100644
index f7a12b72..00000000
--- a/source/dbfit/fixture/Insert.cs
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright © 2012 Syterra Software Inc. Includes work Copyright (C) Gojko Adzic 2006-2008 http://gojko.net
-// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.
-// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-
-using fit;
-using dbfit.util;
-using fitSharp.Fit.Operators;
-using fitSharp.Fit.Service;
-using fitSharp.Machine.Engine;
-
-namespace dbfit.fixture {
- public class Insert: ColumnFixture, MemberQueryable {
-
- private readonly IDbEnvironment dbEnvironment;
- private IDbCommand command;
- private String tableName;
-
- // array of parameter accessors for the input command
- // this contains only those accessors that really go into input (i.e. not the primary key
- // column if the database does not support return on insert. for databases that support
- // return on insert, this will be the same as columnAccessors
- private DbParameterAccessor[] accessors;
- private ColumnAccessors columnAccessors;
- private bool[] isOutputColumn;
- public Insert()
- {
- dbEnvironment = DbEnvironmentFactory.DefaultEnvironment;
- }
- public Insert(IDbEnvironment dbEnvironment)
- {
- this.dbEnvironment=dbEnvironment;
- }
- public Insert(IDbEnvironment dbEnvironment, String tableName) {
- this.tableName= tableName;
- this.dbEnvironment = dbEnvironment;
-
- }
- public override void DoRows(Parse rows) {
- if (String.IsNullOrEmpty(tableName) && Args.Length > 0)
- {
- tableName = Args[0];
- }
- else if (tableName == null) {
- tableName=rows.Parts.Text;
- rows = rows.More;
- }
- InitParameters(rows.Parts);
- InitCommand();
- base.DoRows(rows);
- }
- private void InitCommand() {
- String insert = dbEnvironment.BuildInsertCommand(tableName, accessors);
- command = dbEnvironment.CreateCommand(insert,
- CommandType.Text);
- foreach (DbParameterAccessor accessor in accessors) {
- command.Parameters.Add(accessor.DbParameter);
- }
- }
-
- public override void Execute() {
- command.ExecuteNonQuery();
- }
-
- // this method will initialise accessors array from the parameters that
- // really go into the insert command and columnAccessors for all columns
- private void InitParameters(Parse headerCells) {
- Dictionary allParams=
- dbEnvironment.GetAllColumns(tableName);
- columnAccessors = new ColumnAccessors();
- isOutputColumn = new bool[headerCells.Size];
- var paramAccessors=new List();
- for (int i = 0; headerCells != null; i++, headerCells = headerCells.More) {
- String paramName= NameNormaliser.NormaliseName(headerCells.Text);
- DbParameterAccessor currentColumn;
- try
- {
- currentColumn = allParams[paramName];
- }
- catch (KeyNotFoundException)
- {
- Wrong(headerCells);
- throw new ApplicationException("Cannot find column " + paramName);
- }
- isOutputColumn[i] = BindingFactory.CheckIsImpliedBy(headerCells.Text);
- currentColumn.IsBoundToCheckOperation = isOutputColumn[i];
- columnAccessors.Assign(paramName, currentColumn);
- if (isOutputColumn[i])
- {
- if (dbEnvironment.SupportsReturnOnInsert)
- {
- currentColumn.DbParameter.Direction = ParameterDirection.Output;
- paramAccessors.Add(currentColumn);
- }
- else // don't add to paramAccessors
- {
- //columnAccessors.Assign(paramName, new IdRetrievalAccessor(dbEnvironment, currentColumn.DotNetType));
- columnAccessors.Assign(paramName, new IdRetrievalAccessor(dbEnvironment, currentColumn.DotNetType,tableName));
- }
- }
- else // not output
- {
- currentColumn.DbParameter.Direction = ParameterDirection.Input;
- paramAccessors.Add(currentColumn);
- }
- }
- accessors = paramAccessors.ToArray();
- }
-
- public RuntimeMember Find(MemberSpecification specification) {
- return columnAccessors.Find(specification, accessor => specification.MatchesIdentifierName(accessor.Key));
- }
- }
-}
diff --git a/source/dbfit/fixture/Inspect.cs b/source/dbfit/fixture/Inspect.cs
deleted file mode 100644
index 72ac349b..00000000
--- a/source/dbfit/fixture/Inspect.cs
+++ /dev/null
@@ -1,134 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using dbfit.util;
-using dbfit;
-using fit;
-using System.Data.Common;
-using System.Data;
-namespace dbfit.fixture
-{
- public class Inspect:fit.Fixture
- {
- private IDbEnvironment environment;
- private String objectName;
- private String mode;
- public static String MODE_PROCEDURE="PROCEDURE";
- public static String MODE_TABLE="TABLE";
- public static String MODE_QUERY="QUERY";
-
- public Inspect()
- {
- this.environment = DbEnvironmentFactory.DefaultEnvironment;
- }
- public Inspect(IDbEnvironment dbEnvironment, String mode, String objName) {
- this.objectName= objName;
- this.mode=mode;
- this.environment = dbEnvironment;
- }
- public override void DoTable(Parse table) {
- if (objectName==null) objectName=Args[0];
- try{
- if (MODE_PROCEDURE.Equals(mode))
- InspectProcedure(table);
- else if (MODE_TABLE.Equals(mode))
- InspectTable(table);
- else if (MODE_QUERY.Equals(mode))
- InspectQuery(table);
- else throw new Exception("Unknown inspect mode "+mode);
- }
- catch (Exception e){
- Exception(table.Parts.Parts,e);
- }
- }
- private void InspectTable(Parse table) {
- Dictionary allParams=
- environment.GetAllColumns(objectName);
- if (allParams.Count==0){
- throw new ApplicationException("Cannot retrieve list of columns for table or view "+objectName + " - check spelling and access rights");
- }
- addRowWithParamNames(table,allParams);
- }
- private void InspectProcedure(Parse table) {
- Dictionary allParams=
- environment.GetAllProcedureParameters(objectName);
- if (allParams.Count==0){
- throw new ApplicationException("Cannot retrieve list of parameters for procedure "+objectName + " - check spelling and access rights");
- }
- addRowWithParamNames(table,allParams);
- }
- private void InspectQuery(Parse table) {
- var dc = environment.CreateCommand(objectName, CommandType.Text);
- environment.BindFixtureSymbols(Symbols, dc);
-
- DbDataAdapter oap = environment.DbProviderFactory.CreateDataAdapter();
- oap.SelectCommand = (DbCommand)dc;
- DataSet ds = new DataSet();
- oap.Fill(ds);
- dc.Dispose();
- DataTable dtbl=ds.Tables[0];
-
- Parse newRow=getHeaderFromRS(dtbl);
- table.Parts.More=newRow;
- foreach (DataRow dr in dtbl.Rows){
- newRow.More = getDataRow(dr);
- newRow=newRow.More;
- }
-
- }
- private Parse getDataRow(DataRow rs) {
- Parse newRow=new Parse("tr",null,null,null);
- Parse prevCell=null;
- for (int i=0; i procparams){
- Parse newRow=new Parse("tr",null,null,null);
- table.Parts.More=newRow;
- Parse prevCell=null;
- String[] orderedNames=new String[procparams.Count];
- foreach(String s in procparams.Keys){
- orderedNames[procparams[s].Position]=s;
- }
- for(int i=0; i(0),
- DbEnvironmentFactory.DefaultEnvironment).Rows.GetEnumerator());
- base.DoTable(table);
- }
-
- protected override ListMatchStrategy MatchStrategy {
- get { return new QueryMatchStrategy(Processor, myHeaderRow, isOrdered); }
- }
-
- private class QueryMatchStrategy: NamedMatchStrategy {
- private readonly bool isOrdered;
- public QueryMatchStrategy(CellProcessor processor, Parse theHeaderRow, bool isOrdered)
- : base(processor, theHeaderRow) {
- this.isOrdered = isOrdered;
- }
- public override bool IsOrdered {get { return isOrdered; }}
- public override bool SurplusAllowed {get {return false;}}
-
- public override bool CellMatches(TypedValue actualValue, Tree expectedCell, int columnNumber) {
- if (myHeaderRow.Branches[columnNumber].Value.Text.EndsWith("?")) return true;
- if (expectedCell.Value.Text.Length == 0) return true;
- return base.CellMatches(actualValue, expectedCell, columnNumber);
- }
- }
- }
-}
diff --git a/source/dbfit/fixture/QueryStats.cs b/source/dbfit/fixture/QueryStats.cs
deleted file mode 100644
index 57414354..00000000
--- a/source/dbfit/fixture/QueryStats.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Data;
-using System.Data.Common;
-namespace dbfit.fixture
-{
- public class QueryStats:fit.ColumnFixture
- {
- private IDbEnvironment environment;
- public QueryStats()
- {
- environment = DbEnvironmentFactory.DefaultEnvironment;
- }
- public QueryStats(IDbEnvironment environment)
- {
- this.environment = environment;
- }
- public string TableName;
- public string ViewName { set { TableName=value;}}
- public string Where;
- public string Query;
- private bool hasExecuted=false;
- public override void Reset()
- {
- hasExecuted = false;
- Where = null;
- Query = null;
- _rows = 0;
- TableName = null;
- }
- private int _rows;
- private void execQuery()
- {
- if (hasExecuted) return;
- if (Query == null)
- {
- Query = "select count(*) from " + TableName + (Where != null ? " where " + Where : "");
- var dc = environment.CreateCommand(Query, CommandType.Text);
- object o=dc.ExecuteScalar();
- dc.Dispose();
- if (o != null) _rows = Convert.ToInt32(o);
- }
- else
- {
- var dc = environment.CreateCommand(Query, CommandType.Text);
- environment.BindFixtureSymbols(Symbols, dc);
-
- DbDataAdapter oap = environment.DbProviderFactory.CreateDataAdapter();
- oap.SelectCommand = (DbCommand)dc;
- DataSet ds = new DataSet();
- oap.Fill(ds);
- dc.Dispose();
- _rows=ds.Tables[0].Rows.Count;
- }
- hasExecuted = true;
- }
- public int RowCount()
- {
- execQuery();
- return _rows;
- }
- public bool IsEmpty()
- {
- return RowCount()==0;
- }
- }
-}
diff --git a/source/dbfit/fixture/SetParameter.cs b/source/dbfit/fixture/SetParameter.cs
deleted file mode 100644
index 06d59bf1..00000000
--- a/source/dbfit/fixture/SetParameter.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using System;
-using fitSharp.Machine.Engine;
-
-namespace dbfit.fixture
-{
- public class SetParameter : fit.Fixture
- {
- public static void SetParameterValue(Symbols symbols, String name, Object value)
- {
- if (value == null || "null".Equals(value.ToString().ToLower()))
- {
- symbols.Save(name, DBNull.Value);
- }
- else if (value != null && value.ToString().StartsWith("<<"))
- {
- string varname = value.ToString().Substring(2);
- if (!name.Equals(varname))
- {
- symbols.Save(name, symbols.GetValueOrDefault(varname, null));
- }
- }
- else
- symbols.Save(name, value);
- }
- public override void DoTable(fit.Parse table)
- {
- SetParameterValue(Symbols, Args[0], GetArgumentInput(1, typeof(object)));
- }
- }
-}
diff --git a/source/dbfit/fixture/SetTableParameter.cs b/source/dbfit/fixture/SetTableParameter.cs
deleted file mode 100644
index 487e7838..00000000
--- a/source/dbfit/fixture/SetTableParameter.cs
+++ /dev/null
@@ -1,138 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-
-using fit;
-using dbfit.util;
-using fitSharp.Fit.Operators;
-using fitSharp.Fit.Service;
-using fitSharp.Machine.Engine;
-
-namespace dbfit.fixture
-{
- public class SetTableParameter : ColumnFixture, MemberQueryable
- {
- private readonly IDbEnvironment dbEnvironment;
- private String parameterTableName;
- private String parameterTableType;
- private Symbols symbols;
-
- private DbParameterAccessor[] accessors;
- private ColumnAccessors columnAccessors;
- private bool[] isOutputColumn;
- private DataTable table;
-
- public SetTableParameter()
- {
- dbEnvironment = DbEnvironmentFactory.DefaultEnvironment;
- }
- public SetTableParameter(IDbEnvironment dbEnvironment)
- {
- this.dbEnvironment = dbEnvironment;
- }
- public SetTableParameter(IDbEnvironment dbEnvironment, Symbols symbols, String parameterTableName, String parameterTableType)
- {
- this.parameterTableName = parameterTableName;
- this.parameterTableType = parameterTableType;
- this.dbEnvironment = dbEnvironment;
- this.symbols = symbols;
- table = new DataTable();
- }
-
- public override void DoRows(Parse rows)
- {
- if (String.IsNullOrEmpty(parameterTableName) && Args.Length > 0)
- {
- parameterTableName = Args[0];
- }
- else if (parameterTableName == null)
- {
- parameterTableName = rows.Parts.Text;
- rows = rows.More;
- }
- InitParameters(rows.Parts);
-
- symbols.Save(parameterTableName, new TableTypeParameter(parameterTableType, table));
-
- base.DoRows(rows);
- }
- public override void DoRow(Parse row)
- {
- HasExecuted = false;
- try
- {
- Reset();
- base.DoRow(row);
- if (!HasExecuted)
- {
- var CurrentRow = table.NewRow();
- foreach (DbParameterAccessor accessor in accessors)
- {
- CurrentRow[accessor.DbParameter.ParameterName] = accessor.DbParameter.Value;
- }
- table.Rows.Add(CurrentRow);
- }
- }
- catch (Exception e)
- {
- TestStatus.MarkException(row.Leaf, e);
- }
- }
-
- // this method will initialise accessors array from the parameters that
- // really go into the insert command and columnAccessors for all columns
- private void InitParameters(Parse headerCells)
- {
- Dictionary allParams =
- dbEnvironment.GetAllColumns(parameterTableType);
- columnAccessors = new ColumnAccessors();
- isOutputColumn = new bool[headerCells.Size];
- var paramAccessors = new List();
- for (int i = 0; headerCells != null; i++, headerCells = headerCells.More)
- {
- String paramName = NameNormaliser.NormaliseName(headerCells.Text);
- DbParameterAccessor currentColumn;
- try
- {
- currentColumn = allParams[paramName];
- }
- catch (KeyNotFoundException)
- {
- Wrong(headerCells);
- throw new ApplicationException("Cannot find column " + paramName);
- }
- isOutputColumn[i] = BindingFactory.CheckIsImpliedBy(headerCells.Text);
- currentColumn.IsBoundToCheckOperation = isOutputColumn[i];
- columnAccessors.Assign(paramName, currentColumn);
- if (isOutputColumn[i])
- {
- if (dbEnvironment.SupportsReturnOnInsert)
- {
- currentColumn.DbParameter.Direction = ParameterDirection.Output;
- paramAccessors.Add(currentColumn);
- }
- else // don't add to paramAccessors
- {
- //columnAccessors.Assign(paramName, new IdRetrievalAccessor(dbEnvironment, currentColumn.DotNetType));
- columnAccessors.Assign(paramName, new IdRetrievalAccessor(dbEnvironment, currentColumn.DotNetType, parameterTableType));
- }
- }
- else // not output
- {
- currentColumn.DbParameter.Direction = ParameterDirection.Input;
- paramAccessors.Add(currentColumn);
- }
-
- table.Columns.Add(currentColumn.DbFieldName, currentColumn.DotNetType);
- }
- accessors = paramAccessors.ToArray();
- }
-
- public RuntimeMember Find(MemberSpecification specification)
- {
- return columnAccessors.Find(specification, accessor => specification.MatchesIdentifierName(accessor.Key));
- }
-
- }
-}
diff --git a/source/dbfit/fixture/StoreQuery.cs b/source/dbfit/fixture/StoreQuery.cs
deleted file mode 100644
index 1d4d2b53..00000000
--- a/source/dbfit/fixture/StoreQuery.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System;
-using fit;
-using fitSharp.Fit.Model;
-using fitSharp.Machine.Model;
-
-namespace dbfit.fixture
-{
- public class StoreQuery:fit.Fixture
- {
- private IDbEnvironment dbEnvironment;
- private String query;
- private String symbolName;
- public StoreQuery()
- {
- dbEnvironment = DbEnvironmentFactory.DefaultEnvironment;
- }
- public StoreQuery(IDbEnvironment environment, String query, String symbolName)
- {
- this.dbEnvironment = environment;
- this.query = query;
- this.symbolName = symbolName;
- }
-
- public override void DoTable(Parse table)
- {
- if (query == null || symbolName == null)
- {
- if (Args.Length < 2) throw new ApplicationException("No query and symbol name specified to StoreQuery constructor or argument list");
- query = Args[0];
- symbolName = Args[1];
- }
- if (symbolName.StartsWith(">>")) symbolName = symbolName.Substring(2);
- Symbols.Save(symbolName, DatabaseTest.GetDataTable(Symbols, query,dbEnvironment));
- }
-
- }
-}
diff --git a/source/dbfit/fixture/Update.cs b/source/dbfit/fixture/Update.cs
deleted file mode 100644
index 0439c31d..00000000
--- a/source/dbfit/fixture/Update.cs
+++ /dev/null
@@ -1,125 +0,0 @@
-// Copyright © 2012 Syterra Software Inc. Includes work Copyright (C) Gojko Adzic 2006-2008 http://gojko.net
-// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.
-// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-using dbfit.util;
-using fit;
-using fitSharp.Fit.Operators;
-using fitSharp.Machine.Engine;
-
-namespace dbfit.fixture {
- public class Update: ColumnFixture, MemberQueryable {
- private readonly IDbEnvironment dbEnvironment;
- private IDbCommand command;
- private String tableName;
- private DbParameterAccessor[] updateAccessors;
- private DbParameterAccessor[] selectAccessors;
- private ColumnAccessors columnAccessors;
- private Parse headerCells;
- private Parse currentHeader;
-
- public Update(){
- dbEnvironment = DbEnvironmentFactory.DefaultEnvironment;
- }
- public Update(IDbEnvironment dbEnvironment){
- this.dbEnvironment=dbEnvironment;
- }
- public Update(IDbEnvironment dbEnvironment, String tableName){
- this.tableName= tableName;
- this.dbEnvironment = dbEnvironment;
- }
- public override void DoRows(Parse rows) {
- if (String.IsNullOrEmpty(tableName) && Args.Length > 0){
- tableName = Args[0];
- }
- else if (tableName == null) {
- tableName=rows.Parts.Text;
- rows = rows.More;
- }
- InitParameters(rows.Parts);
- InitCommand();
- headerCells = rows.Parts;
- base.DoRows(rows);
- }
-
- public override void DoCell(Parse cell, int column) {
- currentHeader = headerCells.At(column);
- base.DoCell(cell, column);
- }
-
- private void InitCommand() {
- String ctext=dbEnvironment.BuildUpdateCommand(tableName,updateAccessors,selectAccessors);
- command = dbEnvironment.CreateCommand(ctext,CommandType.Text);
- foreach (DbParameterAccessor accessor in updateAccessors) {
- command.Parameters.Add(accessor.DbParameter);
- }
- foreach (DbParameterAccessor accessor in selectAccessors)
- {
- command.Parameters.Add(accessor.DbParameter);
- }
- }
-
- public override void Execute() {
- command.ExecuteNonQuery();
- }
-
- private void InitParameters(Parse headerCells) {
- Dictionary allParams=
- dbEnvironment.GetAllColumns(tableName);
-
- columnAccessors = new ColumnAccessors();
- IList selectAccList=new List();
- IList updateAccList = new List();
- for (int i = 0; headerCells != null; i++, headerCells = headerCells.More)
- {
- String paramName= NameNormaliser.NormaliseName(headerCells.Text);
- try
- {
- DbParameterAccessor acc = allParams[paramName];
- acc.DbParameter.Direction = ParameterDirection.Input;
- // allow same column to be used in both sides:
- // remap update parameters to u_paramname and select to s_paramname
- acc = DbParameterAccessor.Clone(acc, dbEnvironment);
- if (headerCells.Text.EndsWith("="))
- {
- acc.DbParameter.ParameterName = acc.DbParameter.ParameterName+"_u";
- updateAccList.Add(acc);
- columnAccessors.Assign(paramName +"=", acc);
- }
- else
- {
- acc.DbParameter.ParameterName = acc.DbParameter.ParameterName+"_s";
- selectAccList.Add(acc);
- columnAccessors.Assign(paramName, acc);
- }
- }
- catch (KeyNotFoundException)
- {
- Wrong(headerCells);
- throw new ApplicationException("Cannot find column for " + paramName);
- }
- }
- selectAccessors=new DbParameterAccessor[selectAccList.Count];
- selectAccList.CopyTo(selectAccessors,0);
- updateAccessors = new DbParameterAccessor[updateAccList.Count];
- updateAccList.CopyTo(updateAccessors, 0);
- }
-
- public RuntimeMember Find(MemberSpecification specification) {
- return columnAccessors.Find(specification, accessor => {
- var accessorName = accessor.Key.EndsWith("=")
- ? accessor.Key.Substring(0, accessor.Key.Length - 1)
- : accessor.Key;
- if (!specification.MatchesIdentifierName(accessorName)) return false;
- if (currentHeader != null && currentHeader.Text.EndsWith("=") && !accessor.Key.EndsWith("=")) return false;
- if (currentHeader != null && !currentHeader.Text.EndsWith("=") && accessor.Key.EndsWith("=")) return false;
- return true;
- });
- }
- }
-}
diff --git a/source/dbfit/util/Accessor.cs b/source/dbfit/util/Accessor.cs
deleted file mode 100644
index 9482e94f..00000000
--- a/source/dbfit/util/Accessor.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright © 2010 Syterra Software Inc. Includes work Copyright (C) Gojko Adzic 2006-2008 http://gojko.net
-// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.
-// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-using System;
-
-namespace dbfit.util {
- public interface Accessor {
- object Get();
- void Set(object value);
- Type DotNetType { get; }
- string Name { get; }
- }
-}
diff --git a/source/dbfit/util/ColumnAccessors.cs b/source/dbfit/util/ColumnAccessors.cs
deleted file mode 100644
index bab5d445..00000000
--- a/source/dbfit/util/ColumnAccessors.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-// Copyright © 2012 Syterra Software Inc. Includes work Copyright (C) Gojko Adzic 2006-2008 http://gojko.net
-// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.
-// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-using System;
-using System.Collections.Generic;
-using fitSharp.Machine.Engine;
-using fitSharp.Machine.Model;
-
-namespace dbfit.util {
- public class ColumnAccessors {
- private readonly Dictionary accessors = new Dictionary();
-
- public void Assign(string key, Accessor accessor) {
- accessors[key] = accessor;
- }
-
- public RuntimeMember Find(MemberSpecification specification, Func, bool> filter) {
- foreach (KeyValuePair accessor in accessors) {
- if (!filter(accessor)) continue;
- if (specification.IsSetter) return new SetterMember(accessor.Value);
- if (specification.IsGetter) return new GetterMember(accessor.Value);
- }
- throw new ArgumentException(string.Format("Missing member '{0}'", specification));
- }
-
- private class SetterMember: RuntimeMember {
- private readonly Accessor accessor;
-
- public SetterMember(Accessor accessor) {
- this.accessor = accessor;
- }
-
- public TypedValue Invoke(object[] parameters) {
- accessor.Set(parameters[0]);
- return TypedValue.Void;
- }
-
- public bool MatchesParameterCount(int count) {
- return count == 1;
- }
-
- public Type GetParameterType(int index) {
- return accessor.DotNetType;
- }
-
- public string GetParameterName(int index) {
- return accessor.Name;
- }
-
- public Type ReturnType {
- get { return typeof(void); }
- }
-
- public string Name {
- get { return accessor.Name; }
- }
- }
-
- private class GetterMember: RuntimeMember {
- private readonly Accessor accessor;
-
- public GetterMember(Accessor accessor) {
- this.accessor = accessor;
- }
-
- public TypedValue Invoke(object[] parameters) {
- return new TypedValue(accessor.Get(), accessor.DotNetType);
- }
-
- public bool MatchesParameterCount(int count) {
- return count == 0;
- }
-
- public Type GetParameterType(int index) {
- return typeof(void);
- }
-
- public string GetParameterName(int index) {
- return accessor.Name;
- }
-
- public Type ReturnType {
- get { return accessor.DotNetType; }
- }
-
- public string Name {
- get { return accessor.Name; }
- }
- }
- }
-}
diff --git a/source/dbfit/util/ColumnMissingException.cs b/source/dbfit/util/ColumnMissingException.cs
deleted file mode 100644
index 453c4723..00000000
--- a/source/dbfit/util/ColumnMissingException.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-// Copyright © 2010 Syterra Software Inc. Includes work Copyright (C) Gojko Adzic 2006-2008 http://gojko.net
-// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.
-// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-using System;
-
-namespace dbfit {
- public class ColumnMissingException : ApplicationException {
- public ColumnMissingException(String name) : base("Cannot find column " + name) { }
- }
-}
diff --git a/source/dbfit/util/DbConnectionProperties.cs b/source/dbfit/util/DbConnectionProperties.cs
deleted file mode 100644
index 040e5137..00000000
--- a/source/dbfit/util/DbConnectionProperties.cs
+++ /dev/null
@@ -1,74 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-
-namespace dbfit
-{
- public sealed class DbConnectionProperties{
- public string Service;
- public string Username;
- public string Password;
- public string DbName;
- public string FullConnectionString;
- private DbConnectionProperties(){}
- public static DbConnectionProperties CreateFromString(String contents)
- {
- int currLine=0;
- String[] lines = contents.Split(new char[]{'\n'});
- DbConnectionProperties props = new DbConnectionProperties();
- foreach (String line in lines)
- {
- currLine++;
- if (line==null) continue;
- String trimline=line.Trim();
- if (trimline.Length == 0) continue;
- if (trimline.StartsWith("#")) continue;
- String[] keyval = trimline.Split(new char[] { '=' },2);
- if (keyval.Length==1) throw new
- ApplicationException("Connection properties format incorrect, line "+currLine+ " does not contain a key-value pair ");
- String key = keyval[0].Trim().ToLower();
- String val = keyval[1].Trim();
- if ("username".Equals(key))
- {
- props.Username = val;
- }
- else if ("password".Equals(key))
- {
- props.Password = val;
- }
- else if ("service".Equals(key))
- {
- props.Service = val;
- }
- else if ("database".Equals(key))
- {
- props.DbName = val;
- }
- else if ("connection-string".Equals(key))
- {
- props.FullConnectionString = val;
- }
- else
- {
- throw new ApplicationException("Unsupported key in properties file:" + key);
- }
-
- }
- if (props.FullConnectionString != null) return props;
- if (props.Service != null && props.Username != null && props.Password != null) return props;
- throw new ApplicationException("You have to define either the full connection string; or service, username and password in the properties file");
- }
- public static DbConnectionProperties CreateFromFile(String path){
- if(!System.IO.File.Exists(path)) throw new ApplicationException("File "+path +" does not exist");
- String s;
- try{
- s=System.IO.File.ReadAllText(path);
- }
- catch (Exception e){
- throw new ApplicationException("Error reading file "+path,e);
- }
- return CreateFromString(s);
- }
- }
-}
\ No newline at end of file
diff --git a/source/dbfit/util/DbParameterAccessor.cs b/source/dbfit/util/DbParameterAccessor.cs
deleted file mode 100644
index ee715d3a..00000000
--- a/source/dbfit/util/DbParameterAccessor.cs
+++ /dev/null
@@ -1,96 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-using dbfit.util;
-using fit;
-
-namespace dbfit {
- public class DbParameterAccessor : Accessor {
- private DbParameter dbp;
- private String actualSqlType;
- private Type dotNetType;
- private String dbFieldName;// this can be used when parameter name in SQL should differ from the data field name
- private bool isBoundToCheckOperation = false;
- private int position;
- public int Position
- {
- get { return position; }
- }
- public String ActualSqlType
- {
- get { return actualSqlType; }
- }
- public Type DotNetType
- {
- get { return dotNetType;}
- }
-
- public string Name {
- get { return DbParameter.ParameterName; }
- }
-
- public DbParameter DbParameter
- {
- get { return dbp; }
- internal set { dbp = value; }
- }
- public String DbFieldName {
- get { return dbFieldName; }
- }
- public bool IsBoundToCheckOperation
- {
- get { return isBoundToCheckOperation; }
- internal set { isBoundToCheckOperation = value; }
- }
- public static DbParameterAccessor Clone(DbParameterAccessor dbacc, IDbEnvironment environment)
- {
- DbParameter cloneP=environment.DbProviderFactory.CreateParameter();
- cloneP.ParameterName=dbacc.DbParameter.ParameterName;
- cloneP.DbType= dbacc.DbParameter.DbType;
- cloneP.Direction= dbacc.DbParameter.Direction;
- cloneP.Size= dbacc.DbParameter.Size;
- cloneP.SourceColumn = dbacc.DbParameter.SourceColumn;
- cloneP.Value=dbacc.DbParameter.Value;
- DbParameterAccessor clone=new DbParameterAccessor(cloneP, dbacc.dotNetType,dbacc.position, dbacc.actualSqlType);
- clone.dbFieldName=dbacc.dbFieldName;
- clone.isBoundToCheckOperation=dbacc.isBoundToCheckOperation;
- return clone;
- }
- public static DbParameterAccessor CloneWithSameParameter(DbParameterAccessor dbacc)
- {
- DbParameterAccessor clone = new DbParameterAccessor(dbacc.DbParameter, dbacc.dotNetType, dbacc.position, dbacc.actualSqlType);
- clone.dbFieldName = dbacc.dbFieldName;
- clone.isBoundToCheckOperation = dbacc.isBoundToCheckOperation;
- return clone;
- }
-
- public DbParameterAccessor(DbParameter dbp, Type dotNetType, int position, String actualSqlType)
- {
- this.dbp = dbp;
- this.dotNetType = dotNetType;
- this.dbFieldName=dbp.ParameterName;
- this.position = position;
- this.actualSqlType = actualSqlType;
- }
- public object Get() {
- if (ParameterDirection.Input.Equals(dbp.Direction))
- throw new NotSupportedException("Cannot use input parameters as output values. Please remove the question mark after " + dbp.ParameterName);
- if (typeof(DataTable).Equals(dotNetType) && (dbp.Value is DbDataReader)) {
- DataTable dt=new DataTable();
- dt.Load((DbDataReader) dbp.Value);
- return dt;
- }
- return dbp.Value;
- }
- public void Set(object value) {
- if (ParameterDirection.Input.Equals(dbp.Direction)
- ||
- ParameterDirection.InputOutput.Equals(dbp.Direction))
- dbp.Value = value==null?DBNull.Value:value;
- else
- throw new NotSupportedException("Cannot use output parameters as input values. Did you forget a question mark after " + dbp.ParameterName);
-
- }
- }
-}
diff --git a/source/dbfit/util/IdRetrievalAccessor.cs b/source/dbfit/util/IdRetrievalAccessor.cs
deleted file mode 100644
index bfe3f11c..00000000
--- a/source/dbfit/util/IdRetrievalAccessor.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Data.Common;
-using System.Data;
-namespace dbfit.util
-{
- public class IdRetrievalAccessor: Accessor
- {
- private IDbEnvironment environment;
- private Type expectedType;
- private String tableName;
- public IdRetrievalAccessor(IDbEnvironment environment, Type expectedType)
- {
- this.environment = environment;
- this.expectedType = expectedType;
- }
- public IdRetrievalAccessor(IDbEnvironment environment, Type expectedType, String tableName)
- {
- this.environment = environment;
- this.expectedType = expectedType;
- this.tableName = tableName;
- }
- public object Get()
- {
- if (environment.SupportsReturnOnInsert)
- throw new ApplicationException(environment.GetType() +
- " supports return on insert, IdRetrievalAccessor should not be used");
- var cmd = environment.CreateCommand(environment.IdentitySelectStatement(tableName), CommandType.Text);
- // Console.WriteLine(environment.IdentitySelectExpression);
- object value = cmd.ExecuteScalar();
- value=Convert.ChangeType(value, expectedType);
- //Console.WriteLine("value=" + value + " of " + value.GetType());
- return (DBNull.Value.Equals(value) ? null : value);
- }
- public void Set(object value)
- {
- }
-
- public Type DotNetType {
- get { return expectedType; }
- }
-
- public string Name {
- get { return string.Empty; }
- }
- }
-}
diff --git a/source/dbfit/util/NameNormaliser.cs b/source/dbfit/util/NameNormaliser.cs
deleted file mode 100644
index 46cd6d70..00000000
--- a/source/dbfit/util/NameNormaliser.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Text.RegularExpressions;
-
-namespace dbfit.util {
- public class NameNormaliser {
- private static Regex replaceIllegalCharactersWithSpacesRegex = new Regex(@"[^a-zA-Z0-9_.#]");
- private static string ReplaceIllegalCharacters(string name) {
- return replaceIllegalCharactersWithSpacesRegex.Replace(name, "");
- }
- public static String NormaliseName(String name) {
- if (name == null) return "";
- return ReplaceIllegalCharacters(name.ToLower());
- }
- }
-}
diff --git a/source/dbfit/util/Options.cs b/source/dbfit/util/Options.cs
deleted file mode 100644
index 03cf4b63..00000000
--- a/source/dbfit/util/Options.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright © 2010 Syterra Software Inc. Includes work Copyright (C) Gojko Adzic 2006-2008 http://gojko.net
-// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.
-// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-using System;
-using fitSharp.Fit.Engine;
-using fitSharp.Fit.Operators;
-
-namespace dbfit.util
-{
- public class Options
- {
- private static bool fixedLengthStringParsing;
- private static bool bindSymbols = true;
- private static int commandTimeOut = 30;
-
- public static void reset()
- {
- fixedLengthStringParsing = false;
- bindSymbols = true;
- commandTimeOut = 30;
- }
- public static bool IsFixedLengthStringParsing()
- {
- return fixedLengthStringParsing;
- }
- public static bool ShouldBindSymbols()
- {
- return bindSymbols;
- }
- public static int CommandTimeOut { get { return commandTimeOut; } }
-
- public static void SetOption(CellProcessor processor, String name, String value)
- {
- String normalname = NameNormaliser.NormaliseName(name);
- if ("fixedlengthstringparsing".Equals(normalname))
- {
- fixedLengthStringParsing = Boolean.Parse(value);
- if (fixedLengthStringParsing)
- processor.AddOperator(typeof(ParseQuotedString).FullName);
- else
- processor.RemoveOperator(typeof(ParseQuotedString).FullName);
- }
- else if ("bindsymbols".Equals(normalname))
- {
- bindSymbols = Boolean.Parse(value);
- }
- else if (normalname == "commandtimeout")
- {
- commandTimeOut = int.Parse(value);
- }
- else throw new ApplicationException("Unsupported option" + name);
- }
- }
-}
diff --git a/source/dbfit/util/TableTypeParameter.cs b/source/dbfit/util/TableTypeParameter.cs
deleted file mode 100644
index 0d418ac6..00000000
--- a/source/dbfit/util/TableTypeParameter.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using System;
-using System.Data;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace dbfit.util
-{
- public class TableTypeParameter
- {
- String _tabletype;
- DataTable _datatable;
-
- public TableTypeParameter(String tabletype, DataTable datatable)
- {
- _tabletype = tabletype;
- _datatable = datatable;
- }
-
- public String Tabletype { get { return _tabletype; } }
-
- public DataTable Datatable { get { return _datatable; } }
-
- }
-}
diff --git a/source/dbfitMySql/MySqlEnvironment.cs b/source/dbfitMySql/MySqlEnvironment.cs
deleted file mode 100644
index 4e7810e2..00000000
--- a/source/dbfitMySql/MySqlEnvironment.cs
+++ /dev/null
@@ -1,268 +0,0 @@
-// Copyright © 2011 Ed Harper Includes work Copyright (C) Gojko Adzic 2006-2008 http://gojko.net
-// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.
-// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-using System.Text;
-using MySql.Data.Types;
-using MySql.Data.MySqlClient;
-using System.Text.RegularExpressions;
-using dbfit.util;
-
-namespace dbfit
-{
- ///
- /// Implementation of IDbEnvironment that works with MySql
- ///
- public class MySqlEnvironment : AbstractDbEnvironment
- {
- private const int MAX_STRING_SIZE = 65535;
- protected override String GetConnectionString(String dataSource, String username, String password, String databaseName)
- {
- return String.Format("data source={0};user id={1};password={2};database={3};", dataSource, username, password, databaseName);
- }
-
- protected override String GetConnectionString(String dataSource, String username, String password)
- {
- return String.Format("Data Source={0}; User ID={1}; Password={2}", dataSource, username, password);
- }
- private static readonly DbProviderFactory dbp = DbProviderFactories.GetFactory("MySql.Data.MySqlClient");
- private readonly Regex paramNames = new Regex("@([A-Za-z0-9_]*)");
- private readonly Regex multispaces = new Regex("\\s+");
- protected override Regex ParamNameRegex { get { return paramNames; } }
-
- public override DbProviderFactory DbProviderFactory
- {
- get { return dbp; }
- }
- public override Dictionary GetAllProcedureParameters(String procName) //done
- {
- String[] qualifiers = NameNormaliser.NormaliseName(procName).Split('.');
- String qry = " select type,param_list,returns from mysql.proc where ";
- if (qualifiers.Length == 2)
- {
- qry += " lower(db)=@schema and lower(name)=@objname ";
- }
- else
- {
- qry += " (db=database() and lower(name)=@objname)";
- }
- //Console.WriteLine(qry);
- Dictionary res = ProcedureReadIntoParams(qualifiers, qry);
- if (res.Count == 0) throw new ApplicationException("Cannot read list of parameters for " + procName + " - check spelling and access privileges");
- return res;
- }
- public override Dictionary GetAllColumns(String tableOrViewName) //done
- {
- String[] qualifiers = NameNormaliser.NormaliseName(tableOrViewName).Split('.');
- String qry = @" select column_name, data_type, character_maximum_length, 'IN' as direction from information_schema.columns where ";
- if (qualifiers.Length == 2)
- {
- qry += " lower(table_schema)=@schema and lower(table_name)=@objname ";
- }
- else
- {
- qry += @" (table_schema=database() and lower(table_name)=@objname)";
- }
- qry += " order by ordinal_position ";
- //Console.WriteLine(qry);
- Dictionary res = ReadIntoParams(qualifiers, qry);
- if (res.Count == 0) throw new ApplicationException("Cannot read list of columns for " + tableOrViewName + " - check spelling and access privileges");
- return res;
- }
-
-
- private Dictionary ProcedureReadIntoParams(String[] queryParameters, String query) //done
- {
- var reader = ExecuteParameterQuery(queryParameters, query);
- Dictionary
- allParams = new Dictionary();
- reader.Read();
- String procType = (reader.IsDBNull(0)) ? null : reader.GetString(0);
- String paramList = multispaces.Replace(reader.GetString(1)," ");
- String returns = reader.GetString(2);
- reader.Close();
- int position = 0;
- foreach (string param in paramList.Split(','))
- {
- string[] tokens = param.Trim().ToLower().Split(new char[] { ' ' , '(' , ')' });
- int i = 0;
- string direction = "";
- string paramName = "";
- string dataType = "";
- int length = 0;
-
- if (tokens[i].Equals("in") || tokens[i].Equals("out") || tokens[i].Equals("inout"))
- {
- direction = tokens[i];
- i++;
- }
- else
- {
- direction = "in";
- }
- paramName = tokens[i];
- i++;
- dataType = tokens[i];
- i++;
-
- if (i <= tokens.Length -1 && !Int32.TryParse(tokens[i],out length))
- {
- length = 0;
- }
-
- MySqlParameter dp = BuildMySqlParameter(direction, paramName, dataType, length);
- allParams[NameNormaliser.NormaliseName(paramName)] =
- new DbParameterAccessor(dp, GetDotNetType(dataType), position++, dataType);
- }
- if(procType.Equals("FUNCTION"))
- {
- string[] tokens = returns.Trim().ToLower().Split(new char[] { ' ', '(', ')' });
- string paramName = "?";
- string dataType = tokens[0];
- MySqlParameter dp = BuildMySqlParameter("return", paramName, dataType, -1);
- allParams[NameNormaliser.NormaliseName(paramName)] =
- new DbParameterAccessor(dp, GetDotNetType(dataType), position++, dataType);
- }
- return allParams;
- }
-
- private static MySqlParameter BuildMySqlParameter(string direction, string paramName, string dataType, int length)
- {
- MySqlParameter dp = new MySqlParameter();
- dp.Direction = GetParameterDirection(direction);
- if (paramName != null)
- {
- dp.ParameterName = paramName; dp.SourceColumn = paramName;
- }
- else
- {
- dp.Direction = ParameterDirection.ReturnValue;
- }
-
- dp.MySqlDbType = GetDBType(dataType);
- if (length > 0)
- {
- dp.Size = length;
- }
- else
- {
- if (!ParameterDirection.Input.Equals(dp.Direction) || typeof(String).Equals(GetDotNetType(dataType))) dp.Size = MAX_STRING_SIZE;
- }
- return dp;
- }
-
- private Dictionary ReadIntoParams(String[] queryParameters, String query) //done
- {
- var reader = ExecuteParameterQuery(queryParameters, query);
- Dictionary
- allParams = new Dictionary();
- int position = 0;
- while (reader.Read())
- {
-
- String paramName = (reader.IsDBNull(0)) ? null : reader.GetString(0);
- String dataType = reader.GetString(1);
- int length = (reader.IsDBNull(2)) ? 0 : reader.GetInt32(2);
- String direction = reader.GetString(3);
- MySqlParameter dp = BuildMySqlParameter(direction, paramName, dataType, length);
- allParams[NameNormaliser.NormaliseName(paramName)] =
- new DbParameterAccessor(dp, GetDotNetType(dataType), position++, dataType);
- }
- reader.Close();
- return allParams;
- }
-
- private IDataReader ExecuteParameterQuery(String[] queryParameters, String query)
- {
- var cnx = CurrentConnection;
- var dc = cnx.CreateCommand();
- dc.Transaction = (DbTransaction)CurrentTransaction;
- dc.CommandText = query;
- dc.CommandType = CommandType.Text;
- if (queryParameters.Length == 2)
- {
- AddInput(dc, "@schema", queryParameters[0]);
- AddInput(dc, "@objname", queryParameters[1]);
- }
- else
- {
- AddInput(dc, "@objname", queryParameters[0]);
- }
- var reader = dc.ExecuteReader();
- return reader;
- }
- //datatypes done
- private static string[] StringTypes = new string[] { "VARCHAR", "CHAR", "TEXT" };
- private static string[] IntTypes = new string[] { "TINYINT", "SMALLINT", "MEDIUMINT", "INT", "INTEGER" };
- private static string[] LongTypes = new string[] { "BIGINT", "INTEGER UNSIGNED", "INT UNSIGNED" };
- private static string[] FloatTypes = new string[] { "FLOAT" };
- private static string[] DoubleTypes = new string[] { "DOUBLE" };
- private static string[] DecimalTypes = new string[] { "DECIMAL", "DEC" };
- private static string[] DateTypes = new string[] { "DATE" };
- private static string[] TimestampTypes = new string[] { "TIMESTAMP", "DATETIME" };
- //\done
-
- private static string NormaliseTypeName(string dataType) //done
- {
- dataType = dataType.ToUpper().Trim();
- return dataType;
- }
- private static MySqlDbType GetDBType(String dataType) //done
- {
- //todo:strip everything from first blank
- dataType = NormaliseTypeName(dataType);
-
- if (Array.IndexOf(StringTypes, dataType) >= 0) return MySqlDbType.VarChar;
- if (Array.IndexOf(IntTypes, dataType) >= 0) return MySqlDbType.Int32;
- if (Array.IndexOf(LongTypes, dataType) >= 0) return MySqlDbType.Int64;
- if (Array.IndexOf(FloatTypes, dataType) >= 0) return MySqlDbType.Float;
- if (Array.IndexOf(DoubleTypes, dataType) >= 0) return MySqlDbType.Double;
- if (Array.IndexOf(DecimalTypes, dataType) >= 0) return MySqlDbType.Decimal;
- if (Array.IndexOf(DateTypes, dataType) >= 0) return MySqlDbType.Date;
- if (Array.IndexOf(TimestampTypes, dataType) >= 0) return MySqlDbType.DateTime;
- throw new NotSupportedException("Type " + dataType + " is not supported");
- }
- private static Type GetDotNetType(String dataType) //done
- {
- dataType = NormaliseTypeName(dataType);
- if (Array.IndexOf(StringTypes, dataType) >= 0) return typeof(string);
- if (Array.IndexOf(IntTypes, dataType) >= 0) return typeof(Int32);
- if (Array.IndexOf(LongTypes, dataType) >= 0) return typeof(long);
- if (Array.IndexOf(FloatTypes, dataType) >= 0) return typeof(float);
- if (Array.IndexOf(DoubleTypes, dataType) >= 0) return typeof(double);
- if (Array.IndexOf(DecimalTypes, dataType) >= 0) return typeof(decimal);
- if (Array.IndexOf(DateTypes, dataType) >= 0) return typeof(DateTime);
- if (Array.IndexOf(TimestampTypes, dataType) >= 0) return typeof(DateTime);
- throw new NotSupportedException("Type " + dataType + " is not supported");
- }
- private static ParameterDirection GetParameterDirection(String direction)
- {
- if ("in".Equals(direction.ToLower())) return ParameterDirection.Input;
- if ("out".Equals(direction.ToLower())) return ParameterDirection.Output;
- if ("inout".Equals(direction.ToLower())) return ParameterDirection.InputOutput;
- if ("return".Equals(direction.ToLower())) return ParameterDirection.ReturnValue;
- throw new NotSupportedException("Direction " + direction + " is not supported");
- }
-
- public override int GetExceptionCode(Exception dbException) //done
- {
- if (dbException is MySql.Data.MySqlClient.MySqlException)
- return ((MySql.Data.MySqlClient.MySqlException)dbException).ErrorCode;
- else if (dbException is System.Data.Common.DbException)
- return ((System.Data.Common.DbException)dbException).ErrorCode;
- else return 0;
- }
- public override String ParameterPrefix //done
- {
- get { return "@"; }
- }
- public override bool SupportsReturnOnInsert { get { return false; } } //done
- public override String IdentitySelectStatement(string tableName) { return "select last_insert_id();"; } //done
-
- }
-}
diff --git a/source/dbfitMySql/MySqlTest.cs b/source/dbfitMySql/MySqlTest.cs
deleted file mode 100644
index fb33a00e..00000000
--- a/source/dbfitMySql/MySqlTest.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace dbfit
-{
- public class MySqlTest : DatabaseTest
- {
- public MySqlTest()
- : base(new MySqlEnvironment())
- {
-
- }
- }
-}
diff --git a/source/dbfitMySql/Properties/AssemblyInfo.cs b/source/dbfitMySql/Properties/AssemblyInfo.cs
deleted file mode 100644
index 725351ad..00000000
--- a/source/dbfitMySql/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle("DbFit MySql for fitSharp")]
-[assembly: AssemblyDescription("DbFit. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.")]
-[assembly: AssemblyProduct("fitSharp")]
-[assembly: ComVisible(false)]
-
-[assembly: AssemblyCopyright("Copyright © 2022 Syterra Software Inc. All rights reserved.")]
-[assembly: AssemblyVersion("2022.1.15.0")]
diff --git a/source/dbfitMySql/dbfitMySql.csproj b/source/dbfitMySql/dbfitMySql.csproj
deleted file mode 100644
index 307c2c5a..00000000
--- a/source/dbfitMySql/dbfitMySql.csproj
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- net48;net8.0;net8.0-windows;net9.0;net9.0-windows
- dbfit.MySql
- dbfit.MySql
- false
- false
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/source/dbfitOracle/OracleEnvironment.cs b/source/dbfitOracle/OracleEnvironment.cs
deleted file mode 100644
index 8ac28f5f..00000000
--- a/source/dbfitOracle/OracleEnvironment.cs
+++ /dev/null
@@ -1,217 +0,0 @@
-/// Copyright (C) Gojko Adzic 2006-2008 http://gojko.net
-/// Released under GNU GPL 2.0
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-using System.Data.OracleClient;
-using System.Text.RegularExpressions;
-using System.Xml;
-using System.Text;
-using dbfit.util;
-namespace dbfit {
-///
-/// Implementation of IDbEnvironment that uses Microsoft's ADO.NET driver for Oracle
-///
-
- public class OracleEnvironment : AbstractDbEnvironment {
- protected override String GetConnectionString(String dataSource, String username, String password)
- {
- return String.Format("Data Source={0}; User ID={1}; Password={2}",dataSource,username,password);
- }
- protected override String GetConnectionString(String dataSource, String username, String password, String databaseName)
- {
- return String.Format("Data Source={0}/{3}; User ID={1}; Password={2}", dataSource, username, password,databaseName);
- }
- private Regex paramNames = new Regex(":([A-Za-z0-9_]+)");
- protected override Regex ParamNameRegex { get { return paramNames; } }
-
- private static DbProviderFactory dbp = DbProviderFactories.GetFactory("System.Data.OracleClient");
- public override DbProviderFactory DbProviderFactory
- {
- get { return dbp; }
- }
- public override Dictionary GetAllProcedureParameters(String procName)
- {
- String[] qualifiers = NameNormaliser.NormaliseName(procName).Split('.');
- String cols = " argument_name, data_type, data_length, IN_OUT, sequence ";
- String qry = @" select " + cols + " from all_arguments where data_level=0 and ";
- if (qualifiers.Length == 3) {
- qry += " owner=:0 and package_name=:1 and object_name=:2 ";
- } else if (qualifiers.Length == 2) {
- qry += @" ((owner=:0 and package_name is null and object_name=:1) or
- (owner=user and package_name=:0 and object_name=:1))";
- } else {
- qry += @"
- (owner=user and package_name is null and object_name=:0)";
- }
- // map to public synonyms also
- if (qualifiers.Length<3){
- qry+=@" union all
- select " +cols+@" from all_arguments, all_synonyms
- where data_level=0 and all_synonyms.owner='PUBLIC' and all_arguments.owner=table_owner and ";
- if (qualifiers.Length==2){ // package
- qry+=" package_name=table_name and synonym_name=:0 and object_name=:1 ";
- }
- else {
- qry+=" package_name is null and object_name=table_name and synonym_name=:0 ";
- }
- }
- qry+=" order by sequence ";
- //Console.WriteLine(qry);
- Dictionary res=ReadIntoParams(qualifiers, qry);
- if (res.Count == 0) throw new ApplicationException("Cannot read list of parameters for " + procName + " - check spelling and access privileges");
- return res;
- }
- public override Dictionary GetAllColumns(String tableOrViewName)
- {
- String[] qualifiers = NameNormaliser.NormaliseName(tableOrViewName).Split('.');
- String qry = @" select column_name, data_type, data_length,
- 'IN' as direction, column_id from all_tab_columns where ";
- if (qualifiers.Length == 2) {
- qry += " owner=:0 and table_name=:1 ";
- } else {
- qry += @"
- (owner=user and table_name=:0)";
- }
- qry += " order by column_id ";
- Dictionary res = ReadIntoParams(qualifiers, qry);
- if (res.Count == 0) throw new ApplicationException("Cannot read list of columns for " + tableOrViewName + " - check spelling and access privileges");
- return res;
- }
-
- private Dictionary ReadIntoParams(String[] queryParameters, String query) {
- var cnx = CurrentConnection;
- var dc = cnx.CreateCommand();
- dc.Transaction = (DbTransaction)CurrentTransaction;
- dc.CommandText = query;
- dc.CommandType = CommandType.Text;
- for (int i = 0; i < queryParameters.Length; i++) {
- AddInput(dc, ":" + i, queryParameters[i].ToUpper());
- }
- var reader = dc.ExecuteReader();
- Dictionary
- allParams = new Dictionary();
- int position = 0;
- while (reader.Read()) {
-
- String paramName = (reader.IsDBNull(0)) ? null : reader.GetString(0);
- String dataType = reader.GetString(1);
- int length = (reader.IsDBNull(2)) ? 0 : reader.GetInt32(2);
- String direction = reader.GetString(3);
- OracleParameter dp = new OracleParameter();
- dp.Direction = GetParameterDirection(direction);
- if (paramName != null) {
- dp.ParameterName = paramName; dp.SourceColumn=paramName;
- }
- else {
- dp.Direction = ParameterDirection.ReturnValue;
- }
-
- dp.OracleType = GetDBType(dataType);
- if (length > 0) {
- dp.Size = length;
-
- } else {
- if (!ParameterDirection.Input.Equals(dp.Direction) || typeof(String).Equals(GetDotNetType(dataType)))
- dp.Size = 4000;
- }
- allParams[NameNormaliser.NormaliseName(paramName)] =
- new DbParameterAccessor(dp, GetDotNetType(dataType), position++, dataType);
- }
- return allParams;
- }
- private static string[] StringTypes = new string[] { "VARCHAR", "VARCHAR2", "NVARCHAR2", "CHAR", "NCHAR", "ROWID", "CLOB", "NCLOB", "RAW" };
- private static string[] DecimalTypes = new string[] { "BINARY_INTEGER","NUMBER","FLOAT" };
- private static string[] DateTypes = new string[] { "TIMESTAMP", "DATE" };
- private static string[] RefCursorTypes = new string[] { "REF" };
-
- private static string NormaliseTypeName(string dataType) {
- dataType = dataType.ToUpper().Trim();
- int idx = dataType.IndexOf(" ");
- if (idx >= 0) dataType = dataType.Substring(0, idx);
- idx = dataType.IndexOf("(");
- if (idx >= 0) dataType = dataType.Substring(0, idx);
- return dataType;
- }
- private static OracleType GetDBType(String dataType) {
- //todo:strip everything from first blank
- dataType = NormaliseTypeName(dataType);
-
- if (Array.IndexOf(StringTypes, dataType) >= 0) return OracleType.VarChar;
- if (Array.IndexOf(DecimalTypes, dataType) >= 0) return OracleType.Number;
- if (Array.IndexOf(DateTypes, dataType) >= 0) return OracleType.DateTime;
- if (Array.IndexOf(RefCursorTypes, dataType) >= 0) return OracleType.Cursor;
- throw new NotSupportedException("Type " + dataType + " is not supported");
- }
- private static Type GetDotNetType(String dataType) {
- dataType = NormaliseTypeName(dataType);
- if (Array.IndexOf(StringTypes, dataType) >= 0) return typeof(string);
- if (Array.IndexOf(DecimalTypes, dataType) >= 0) return typeof(decimal);
- if (Array.IndexOf(DateTypes, dataType) >= 0) return typeof(DateTime);
- if (Array.IndexOf(RefCursorTypes, dataType) >= 0) return typeof(DataTable);
-
- throw new NotSupportedException("Type " + dataType + " is not supported");
- }
- private static ParameterDirection GetParameterDirection(String direction) {
- if ("IN".Equals(direction)) return ParameterDirection.Input;
- if ("OUT".Equals(direction)) return ParameterDirection.Output;
- if ("IN/OUT".Equals(direction)) return ParameterDirection.InputOutput;
- //todo return val
- throw new NotSupportedException("Direction " + direction + " is not supported");
- }
- public override String BuildInsertCommand(String tableName, DbParameterAccessor[] accessors)
- {
- StringBuilder sb = new StringBuilder("insert into ");
- sb.Append(tableName).Append("(");
- String comma = "";
- String retComma = "";
-
- StringBuilder values = new StringBuilder();
- StringBuilder retNames = new StringBuilder();
- StringBuilder retValues = new StringBuilder();
-
- foreach (DbParameterAccessor accessor in accessors)
- {
- if (!accessor.IsBoundToCheckOperation)
- {
- sb.Append(comma);
- values.Append(comma);
- sb.Append(accessor.DbParameter.SourceColumn);
- values.Append(":").Append(accessor.DbParameter.ParameterName);
- comma = ",";
- }
- else
- {
- retNames.Append(retComma);
- retValues.Append(retComma);
- retNames.Append(accessor.DbParameter.SourceColumn);
- retValues.Append(":").Append(accessor.DbParameter.ParameterName);
- retComma = ",";
- }
- }
- sb.Append(") values (");
- sb.Append(values);
- sb.Append(")");
- if (retValues.Length > 0)
- {
- sb.Append(" returning ").Append(retNames).Append(" into ").Append(retValues);
- }
- return sb.ToString();
- }
- public override int GetExceptionCode(Exception dbException)
- {
- if (dbException is System.Data.OracleClient.OracleException)
- return ((System.Data.OracleClient.OracleException)dbException).Code;
- else if (dbException is System.Data.Common.DbException)
- return ((System.Data.Common.DbException)dbException).ErrorCode;
- else return 0;
- }
- public override String ParameterPrefix{
- get { return ":"; }
- }
- public override bool SupportsReturnOnInsert { get { return true; } }
- public override String IdentitySelectStatement (string tableName){ throw new ApplicationException("Oracle supports return on insert"); }
-
- }
-}
diff --git a/source/dbfitOracle/OracleTest.cs b/source/dbfitOracle/OracleTest.cs
deleted file mode 100644
index e2ab3386..00000000
--- a/source/dbfitOracle/OracleTest.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace dbfit{
- public class OracleTest:DatabaseTest {
- public OracleTest(): base(new OracleEnvironment()){
-
- }
- }
-}
diff --git a/source/dbfitOracle/Properties/AssemblyInfo.cs b/source/dbfitOracle/Properties/AssemblyInfo.cs
deleted file mode 100644
index db4e47e9..00000000
--- a/source/dbfitOracle/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle("DbFit Oracle for fitSharp")]
-[assembly: AssemblyDescription("DbFit. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.")]
-[assembly: AssemblyProduct("fitSharp")]
-[assembly: ComVisible(false)]
-
-[assembly: AssemblyCopyright("Copyright © 2007 Gojko Adzic, 2022 Syterra Software Inc. All rights reserved.")]
-[assembly: AssemblyVersion("2022.1.15.0")]
diff --git a/source/dbfitOracle/dbfitOracle.csproj b/source/dbfitOracle/dbfitOracle.csproj
deleted file mode 100644
index be98bd60..00000000
--- a/source/dbfitOracle/dbfitOracle.csproj
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
- net48;net8.0;net8.0-windows;net9.0;net9.0-windows
- dbfit.Oracle
- dbfit.Oracle
- false
- false
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/source/dbfitSqlServer/Properties/AssemblyInfo.cs b/source/dbfitSqlServer/Properties/AssemblyInfo.cs
deleted file mode 100644
index 33bf7ee1..00000000
--- a/source/dbfitSqlServer/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle("DbFit SqlServer for fitSharp")]
-[assembly: AssemblyDescription("DbFit. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.")]
-[assembly: AssemblyProduct("fitSharp")]
-[assembly: ComVisible(false)]
-
-[assembly: AssemblyCopyright("Copyright © 2007 Gojko Adzic, 2022 Syterra Software Inc. All rights reserved.")]
-[assembly: AssemblyVersion("2022.1.15.0")]
diff --git a/source/dbfitSqlServer/SqlServer2000Environment.cs b/source/dbfitSqlServer/SqlServer2000Environment.cs
deleted file mode 100644
index 18ed02b9..00000000
--- a/source/dbfitSqlServer/SqlServer2000Environment.cs
+++ /dev/null
@@ -1,139 +0,0 @@
-/// Copyright (C) Gojko Adzic 2006-2008 http://gojko.net
-/// Released under GNU GPL 2.0
-
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-using System.Data.SqlClient;
-using System.Text.RegularExpressions;
-using System.Xml;
-using System.Text;
-using dbfit.util;
-using fit;
-
-namespace dbfit
-{
- ///
- /// Implementation of IDbEnviroment that works with SqlServer versions before 2005
- ///
- class SqlServer2000Environment : SqlServerEnvironment
- {
- public override Dictionary GetAllProcedureParameters(String procName)
- {
- if (procName.Contains("."))
- {
- String[] splitname = procName.Split('.');
- return ReadIntoParams(
- @"select parameter_name,data_type,character_maximum_length, parameter_mode,
- numeric_scale, numeric_precision
- from information_schema.parameters
- where SPECIFIC_NAME=@objname
- and SPECIFIC_SCHEMA=@schemaname
- order by ordinal_position", splitname[0], splitname[1]
- );
- }
- else
- {
- return ReadIntoParams(
- @"select parameter_name,data_type,character_maximum_length, parameter_mode,
- numeric_scale, numeric_precision
- from information_schema.parameters
- where SPECIFIC_NAME=@objname
- and SPECIFIC_SCHEMA in ('dbo',user)
- order by ordinal_position", procName, null
- );
- }
- }
- public override Dictionary GetAllColumns(String tableOrViewName)
- {
- if (tableOrViewName.Contains(".")){
- String[] splitname = tableOrViewName.Split('.');
- return ReadIntoParams(
- @"select column_name,data_type,character_maximum_length,'IN' as parameter_mode,
- numeric_scale, numeric_precision
- from information_schema.columns
- where table_name=@objname
- and table_schema =@schemaname
- order by ordinal_position", splitname[0], splitname[1]
- );
- }
- else {
- return ReadIntoParams(
- @"select column_name,data_type,character_maximum_length,'IN' as parameter_mode,
- numeric_scale, numeric_precision
- from information_schema.columns
- where table_name=@objname
- and table_schema in ('dbo',user)
- order by ordinal_position", tableOrViewName,null
- );
- }
- }
-
- private Dictionary ReadIntoParams(String query, String objname, String schemaname)
- {
- objname = NameNormaliser.NormaliseName(objname);
- var cnx = CurrentConnection;
- var dc = cnx.CreateCommand();
- dc.Transaction = (DbTransaction)CurrentTransaction;
- dc.CommandText = query;
- dc.CommandType = CommandType.Text;
- AddInput(dc, "@objname", objname);
- if (schemaname!=null)
- AddInput(dc, "@schemaname", NameNormaliser.NormaliseName(schemaname));
- var reader = dc.ExecuteReader();
- Dictionary
- allParams = new Dictionary();
- int position=0;
- while (reader.Read())
- {
-
- String paramName = (reader.IsDBNull(0)) ? null : reader.GetString(0);
- String dataType = reader.GetString(1);
- int length = (reader.IsDBNull(2)) ? 0 : System.Convert.ToInt32(reader[2]);
- String direction = (reader.IsDBNull(3)) ? "IN" : reader.GetString(3);
- byte precision = 0;
- byte scale = 0;
- if (!reader.IsDBNull(4))
- scale=System.Convert.ToByte(reader[4]);
- if (!reader.IsDBNull(5))
- precision = System.Convert.ToByte(reader[5]);
-
- SqlParameter dp = new SqlParameter();
- dp.Direction = GetParameterDirection(direction);
- if (!String.IsNullOrEmpty(paramName)) {
- dp.ParameterName = paramName; dp.SourceColumn=paramName;
- }
- else
- {
- dp.Direction = ParameterDirection.ReturnValue;
- }
- dp.SqlDbType= GetDBType(dataType);
- if (precision > 0) dp.Precision = precision;
- if (scale > 0) dp.Scale = scale;
-
- if (length > 0)
- {
- dp.Size = System.Convert.ToInt32(length);
- }
- else
- {
- if (!ParameterDirection.Input.Equals(dp.Direction) || typeof(String).Equals(GetDotNetType(dataType)))
- dp.Size = 4000;
- }
- allParams[NameNormaliser.NormaliseName(paramName)] =
- new DbParameterAccessor(dp, GetDotNetType(dataType), position++, dataType);
- }
- reader.Close();
- if (allParams.Count == 0)
- throw new ApplicationException("Cannot read columns/parameters for object " + objname + " - check spelling or access privileges ");
- return allParams;
- }
- private static ParameterDirection GetParameterDirection(String direction)
- {
- if ("IN".Equals(direction)) return ParameterDirection.Input;
- if ("INOUT".Equals(direction)) return ParameterDirection.Output;
- else return ParameterDirection.Output;
- }
- }
-}
diff --git a/source/dbfitSqlServer/SqlServer2000Test.cs b/source/dbfitSqlServer/SqlServer2000Test.cs
deleted file mode 100644
index fa6d2ade..00000000
--- a/source/dbfitSqlServer/SqlServer2000Test.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace dbfit{
- public class SqlServer2000Test:DatabaseTest {
- public SqlServer2000Test()
- : base(new SqlServer2000Environment())
- {
-
- }
- }
-}
diff --git a/source/dbfitSqlServer/SqlServerEnvironment.cs b/source/dbfitSqlServer/SqlServerEnvironment.cs
deleted file mode 100644
index 111bb860..00000000
--- a/source/dbfitSqlServer/SqlServerEnvironment.cs
+++ /dev/null
@@ -1,297 +0,0 @@
-// Copyright © 2011 Syterra Software Inc. Includes work Copyright (C) Gojko Adzic 2006-2008 http://gojko.net
-// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.
-// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-using System.Data.SqlClient;
-using System.Text.RegularExpressions;
-using dbfit.util;
-using fitSharp.Machine.Engine;
-
-namespace dbfit
-{
- ///
- /// Implementation of IDbEnvironment that works with SqlServer 2005 and newer versions
- ///
- public class SqlServerEnvironment : AbstractDbEnvironment
- {
- private const int MAX_STRING_SIZE = 4000;
- protected override String GetConnectionString(String dataSource, String username, String password, String databaseName)
- {
- return String.Format("data source={0};user id={1};password={2};database={3};", dataSource, username, password, databaseName);
- }
-
- protected override String GetConnectionString(String dataSource, String username, String password)
- {
- return String.Format("Data Source={0}; User ID={1}; Password={2}", dataSource, username, password);
- }
-
- private static readonly DbProviderFactory dbp = SqlClientFactory.Instance;
- private readonly Regex paramNames = new Regex("@([A-Za-z0-9_]*)");
- protected override Regex ParamNameRegex { get { return paramNames;}}
-
- public override DbProviderFactory DbProviderFactory
- {
- get { return dbp; }
- }
- public override Dictionary GetAllProcedureParameters(String procName)
- {
- string dbName = GetDbName(procName);
- string retString = "select p.[name], TYPE_NAME(p.system_type_id) as [Type], p.max_length, p.is_output, p.is_cursor_ref, p.precision, p.scale from ";
- retString += dbName + "sys.parameters p where p.object_id = OBJECT_ID(@objname) ";
- retString += "UNION ALL select '','int',4,1,0,10,0 where EXISTS (SELECT * FROM ";
- retString += dbName + "sys.objects WHERE object_id = OBJECT_ID(@objname) AND type in (N'P', N'PC'))";
-
- return ReadIntoParams(procName, retString);
- }
-
- private static string GetDbName(String objectName)
- {
- String[] objNameArr = objectName.Split(new[] { '.' });
- if (objNameArr.Length == 3)
- {
- //the table is in another database
- return objNameArr[0] + ".";
- }
- return "";
- }
- public override Dictionary GetAllColumns(String tableOrViewOrTypeName)
- {
- string dbName = GetDbName(tableOrViewOrTypeName);
- return ReadIntoParams(tableOrViewOrTypeName,
- @"SELECT c.[name], TYPE_NAME(c.system_type_id) as [Type], c.max_length,
- 0 As is_output, 0 As is_cursor_ref, c.precision, c.scale
- FROM " + dbName + @"sys.columns c
- WHERE c.object_id = COALESCE(OBJECT_ID(@objname), (SELECT type_table_object_id FROM "+ dbName + @"sys.table_types WHERE user_type_id = TYPE_ID(@objname)))
- ORDER BY column_id" );
- }
-
- private Dictionary ReadIntoParams(String objname, String query)
- {
- if (objname.Contains("."))
- {
- // The object name is multi-part an will not be amended
- }
- else
- {
- objname = "[" + NameNormaliser.NormaliseName(objname) + "]";
- }
- var cnx = (SqlConnection)CurrentConnection;
- SqlCommand dc = cnx.CreateCommand();
- dc.Transaction = (SqlTransaction)CurrentTransaction;
- dc.CommandText = query;
- dc.CommandType = CommandType.Text;
- dc.Parameters.Clear();
- AddInput(dc, "objname", objname);
- DbDataReader reader = dc.ExecuteReader();
- var allParams = new Dictionary();
- int position=0;
- while (reader.Read())
- {
- String paramName = (reader.IsDBNull(0)) ? null : reader.GetString(0);
- String dataType = reader.GetString(1);
- int length = (reader.IsDBNull(2)) ? 0 : Convert.ToInt32(reader[2]);
- int isOutput = (reader.IsDBNull(3)) ? 0 : Convert.ToInt32(reader[3]);
- byte precision = Convert.ToByte(reader[5]);
- byte scale = Convert.ToByte(reader[6]);
-
- var dp = new SqlParameter {Direction = GetParameterDirection(isOutput)};
- if (!String.IsNullOrEmpty(paramName)) {
- dp.ParameterName = paramName; dp.SourceColumn=paramName;
- }
- else
- {
- dp.Direction = ParameterDirection.ReturnValue;
- }
- dp.SqlDbType= GetDBType(dataType);
- String typeName = NormaliseTypeName(dataType);
- if (precision > 0) dp.Precision = precision;
- if (scale > 0) dp.Scale = scale;
- if ("NTEXT".Equals(typeName)||("TEXT".Equals(typeName)))
- dp.Size=MAX_STRING_SIZE;
- else if ("NVARCHAR".Equals(typeName) || ("NCHAR".Equals(typeName)))
- {
- dp.Size = System.Convert.ToInt32(length) / 2;
- }
- else if (length > 0)
- {
- dp.Size = Convert.ToInt32(length);
- }
- else
- {
- if (!ParameterDirection.Input.Equals(dp.Direction) ||
- typeof(String).Equals(GetDotNetType(dataType)))
- dp.Size = MAX_STRING_SIZE;
- }
- allParams[NameNormaliser.NormaliseName(paramName)] =
- new DbParameterAccessor(dp, GetDotNetType(dataType), position++, dataType);
- }
- reader.Close();
- dc.Parameters.Clear();
- if (allParams.Count == 0)
- throw new ApplicationException("Cannot read columns/parameters for object " + objname + " - check spelling or access privileges ");
- return allParams;
- }
- private static readonly string[] SingleByteStringTypes = new string[] { "VARCHAR", "CHAR", "TEXT" };
- private static readonly string[] DoubleByteStringTypes = new string[] { "NVARCHAR", "NCHAR", "NTEXT" };
- private static readonly string[] XMLTypes = new string[] { "XML" };
- private static readonly string[] DecimalTypes = new[] { "DECIMAL", "NUMERIC", "MONEY", "SMALLMONEY" };
- private static readonly string[] DateTimeTypes = new[] { "SMALLDATETIME", "DATETIME" };
- private static readonly string[] DateTypes2008 = new[] { "DATETIME2" };
- private static readonly string[] DateTypes = new[] { "DATE" };
- private static readonly string[] TimeTypes = new[] { "TIME" };
- private static readonly string[] DateTimeOffsetTypes = new[] { "DATETIMEOFFSET" };
- private static readonly string[] RefCursorTypes = new[] { "REF" };
- private static readonly string[] Int8Types = new[] { "TINYINT" };
- private static readonly string[] Int16Types = new[] { "SMALLINT" };
- private static readonly string[] Int32Types=new[] {"INT"};
- private static readonly string[] Int64Types = new[] { "BIGINT"};
- private static readonly string[] TimestampTypes = new[] { "ROWVERSION", "TIMESTAMP" };
-
- private static readonly string[] BooleanTypes = new[] { "BIT" };
- private static readonly string[] BinaryTypes = new[] { "BINARY", "VARBINARY", "IMAGE"};//, };
- private static readonly string[] GuidTypes = new[] { "UNIQUEIDENTIFIER" };
- private static readonly string[] VariantTypes = new[] { "SQL_VARIANT" };
- private static readonly string[] FloatTypes = new[] { "FLOAT" };
- private static readonly string[] RealTypes = new[] { "REAL" };
- private static readonly string[] Structured = new[] { "TABLE TYPE" };
-
- private static string NormaliseTypeName(string dataType)
- {
- dataType = dataType.ToUpper().Trim();
- int idx = dataType.IndexOf(" ");
- if (idx >= 0) dataType = dataType.Substring(0, idx);
- idx = dataType.IndexOf("(");
- if (idx >= 0) dataType = dataType.Substring(0, idx);
- return dataType;
- }
- protected static SqlDbType GetDBType(String dataType)
- {
- //todo:strip everything from first blank
- dataType = NormaliseTypeName(dataType);
-
- if (Array.IndexOf(SingleByteStringTypes, dataType) >= 0) return SqlDbType.VarChar;
- if (Array.IndexOf(DoubleByteStringTypes, dataType) >= 0) return SqlDbType.NVarChar;
- if (Array.IndexOf(XMLTypes, dataType) >= 0) return SqlDbType.Xml;
- if (Array.IndexOf(DecimalTypes, dataType) >= 0) return SqlDbType.Decimal;
- if (Array.IndexOf(DateTimeTypes, dataType) >= 0) return SqlDbType.DateTime;
- if (Array.IndexOf(DateTypes2008, dataType) >= 0) return SqlDbType.DateTime2;
- if (Array.IndexOf(DateTypes, dataType) >= 0) return SqlDbType.Date;
- if (Array.IndexOf(TimeTypes, dataType) >= 0) return SqlDbType.Time;
- if (Array.IndexOf(DateTimeOffsetTypes, dataType) >= 0) return SqlDbType.DateTimeOffset;
- if (Array.IndexOf(Int8Types, dataType) >= 0) return SqlDbType.TinyInt;
- if (Array.IndexOf(Int16Types, dataType) >= 0) return SqlDbType.SmallInt;
- if (Array.IndexOf(Int32Types, dataType) >= 0) return SqlDbType.Int;
- if (Array.IndexOf(Int64Types, dataType) >= 0) return SqlDbType.BigInt;
- if (Array.IndexOf(BooleanTypes, dataType) >= 0) return SqlDbType.Bit;
- if (Array.IndexOf(BinaryTypes,dataType)>=0) return SqlDbType.VarBinary;
- if (Array.IndexOf(TimestampTypes, dataType) >= 0) return SqlDbType.Timestamp;
- if (Array.IndexOf(GuidTypes, dataType) >= 0) return SqlDbType.UniqueIdentifier;
- if (Array.IndexOf(VariantTypes, dataType) >= 0) return SqlDbType.Variant;
- if (Array.IndexOf(FloatTypes, dataType) >= 0) return SqlDbType.Float;
- if (Array.IndexOf(RealTypes, dataType) >= 0) return SqlDbType.Real;
- if (Array.IndexOf(Structured, dataType) >= 0) return SqlDbType.Structured;
-
- throw new NotSupportedException("Type " + dataType + " is not supported");
- }
- protected static Type GetDotNetType(String dataType)
- {
- dataType = NormaliseTypeName(dataType);
- if (Array.IndexOf(SingleByteStringTypes, dataType) >= 0) return typeof(string);
- if (Array.IndexOf(DoubleByteStringTypes, dataType) >= 0) return typeof(string);
- if (Array.IndexOf(XMLTypes, dataType) >= 0) return typeof(string);
- if (Array.IndexOf(DecimalTypes, dataType) >= 0) return typeof(decimal);
- if (Array.IndexOf(Int8Types, dataType) >= 0) return typeof(byte);
- if (Array.IndexOf(Int16Types, dataType) >= 0) return typeof(Int16);
- if (Array.IndexOf(Int32Types, dataType) >= 0) return typeof(Int32);
- if (Array.IndexOf(Int64Types, dataType) >= 0) return typeof(Int64);
- if (Array.IndexOf(DateTimeTypes, dataType) >= 0) return typeof(DateTime);
- if (Array.IndexOf(DateTypes, dataType) >= 0) return typeof(DateTime);
- if (Array.IndexOf(DateTypes2008, dataType) >= 0) return typeof(DateTime);
- if (Array.IndexOf(DateTimeOffsetTypes, dataType) >= 0) return typeof(DateTimeOffset);
- if (Array.IndexOf(RefCursorTypes, dataType) >= 0) return typeof(DataTable);
- if (Array.IndexOf(BooleanTypes, dataType) >= 0) return typeof(bool);
- if (Array.IndexOf(BinaryTypes, dataType) >= 0) return typeof(byte[]);
- if (Array.IndexOf(TimestampTypes, dataType) >= 0) return typeof(byte[]);
- if (Array.IndexOf(GuidTypes, dataType) >= 0) return typeof(Guid);
- if (Array.IndexOf(VariantTypes, dataType) >= 0) return typeof(string);
- if (Array.IndexOf(FloatTypes, dataType) >= 0) return typeof(double);
- if (Array.IndexOf(RealTypes, dataType) >= 0) return typeof(float);
- if (Array.IndexOf(TimeTypes, dataType) >= 0) return typeof(TimeSpan);
- if (Array.IndexOf(Structured, dataType) >= 0) return typeof(DataTable);
-
- throw new NotSupportedException(".net Type " + dataType + " is not supported");
- }
- private static ParameterDirection GetParameterDirection(int isOutput) {
- return isOutput==1 ? ParameterDirection.Output : ParameterDirection.Input;
- }
-
- public override bool SupportsReturnOnInsert { get { return false; } }
- public override String IdentitySelectStatement(string tableName) {
- return tableName == null ? "select @@identity" : "select IDENT_CURRENT('" + tableName + "')";
- }
-
- public override int GetExceptionCode(Exception dbException) {
- if (dbException is SqlException)
- {
- Console.WriteLine("SQL Exception " + ((SqlException)dbException).Number);
- return ((SqlException)dbException).Number;
- }
- return base.GetExceptionCode(dbException);
- }
-
- public override string ParameterPrefix
- {
- get { return "@";}
- }
-
- protected override string BuildColumnName(string sourceColumnName)
- {
- return "[" + sourceColumnName + "]";
- }
-
- protected override void AddInput(IDbCommand dbCommand, String name, Object value)
- {
- SqlParameter dbParameter;
- var cmd = (SqlCommand)dbCommand;
-
- var parameter = value as TableTypeParameter;
- if (parameter != null)
- {
- dbParameter = cmd.Parameters.AddWithValue(name, parameter.Datatable );
- dbParameter.Direction = ParameterDirection.Input;
- dbParameter.SqlDbType = SqlDbType.Structured ;
- dbParameter.TypeName = parameter.Tabletype;
- }
- else
- {
- dbParameter = cmd.Parameters.AddWithValue(name, (value ?? DBNull.Value));
- dbParameter.Direction = ParameterDirection.Input;
- }
- }
- public override void BindFixtureSymbols(Symbols symbols, IDbCommand dc)
- {
- foreach (String paramName in ExtractParamNames(dc.CommandText))
- {
- AddInput(dc, paramName, symbols.GetValueOrDefault(paramName, null));
- }
- }
-
- public override IDbCommand CreateCommand(string statement, CommandType commandType)
- {
- if (CurrentConnection == null) throw new ApplicationException("Not connected to database");
-
- var cnx = CurrentConnection;
- var dc = cnx.CreateCommand();
- dc.CommandText = statement.Replace("\r", " ").Replace("\n", " ");
- dc.CommandType = commandType;
- dc.Transaction = CurrentTransaction;
- dc.CommandTimeout = Options.CommandTimeOut;
- return dc;
- }
- }
-}
diff --git a/source/dbfitSqlServer/SqlServerTest.cs b/source/dbfitSqlServer/SqlServerTest.cs
deleted file mode 100644
index 72646404..00000000
--- a/source/dbfitSqlServer/SqlServerTest.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace dbfit{
- public class SqlServerTest:DatabaseTest {
- public SqlServerTest(): base(new SqlServerEnvironment()){
-
- }
- }
-}
diff --git a/source/dbfitSqlServer/dbfitSqlServer.csproj b/source/dbfitSqlServer/dbfitSqlServer.csproj
deleted file mode 100644
index e02643fb..00000000
--- a/source/dbfitSqlServer/dbfitSqlServer.csproj
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
- net48;net8.0;net8.0-windows;net9.0;net9.0-windows
- dbfit.SqlServer
- dbfit.SqlServer
- false
- false
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/source/dbfitSybase/Properties/AssemblyInfo.cs b/source/dbfitSybase/Properties/AssemblyInfo.cs
deleted file mode 100644
index 67283d14..00000000
--- a/source/dbfitSybase/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle("DbFit Sybase for fitSharp")]
-[assembly: AssemblyDescription("DbFit. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.")]
-[assembly: AssemblyProduct("fitSharp")]
-[assembly: ComVisible(false)]
-
-[assembly: AssemblyCopyright("Copyright © 2022 Syterra Software Inc. All rights reserved.")]
-[assembly: AssemblyVersion("2022.1.15.0")]
diff --git a/source/dbfitSybase/SybaseEnvironment.cs b/source/dbfitSybase/SybaseEnvironment.cs
deleted file mode 100644
index 36aca1fc..00000000
--- a/source/dbfitSybase/SybaseEnvironment.cs
+++ /dev/null
@@ -1,264 +0,0 @@
-//
-// Ori Helman
-// 12 Aug 2010
-// Contains an implementation for the Sybase database. It was tested with Sybase 12.5.
-// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND.
-//
-
-using System;
-using System.Collections.Generic;
-using System.Data;
-using System.Data.Common;
-using System.Text.RegularExpressions;
-using dbfit.util;
-using Sybase.Data.AseClient;
-
-namespace dbfit
-{
- public class SybaseEnvironment : AbstractDbEnvironment
- {
- private const int MAX_STRING_SIZE = 32767;
- public override string ParameterPrefix
- {
- get { return "@"; }
- }
-
- protected override string GetConnectionString(string dataSource, string username, string password)
- {
- return String.Format("Data Source={0}; User ID={1}; pwd={2}", dataSource, username, password);
- }
-
- protected override string GetConnectionString(string dataSource, string username, string password, string database)
- {
- return String.Format("Data Source={0}; User ID={1}; pwd={2}; DatabaseName={3}", dataSource, username, password, database);
- }
-
- private Regex paramNames = new Regex("@([A-Za-z0-9_]*)");
- private static DbProviderFactory dbp = new AseClientFactory();
-
- protected override Regex ParamNameRegex
- {
-
- get { return paramNames; }
- }
-
- protected override void AddInput(IDbCommand dbCommand, String name, Object value)
- {
- var cmd = dbCommand;
- var dbParameter = cmd.CreateParameter();
- dbParameter.Direction = ParameterDirection.Input;
- if (!name.StartsWith(ParameterPrefix))
- dbParameter.ParameterName = ParameterPrefix + name;
- else
- dbParameter.ParameterName = name;
- dbParameter.Value = (value == null ? DBNull.Value : value);
- dbCommand.Parameters.Add(dbParameter);
- }
-
-
- public override DbProviderFactory DbProviderFactory
- {
- get { return dbp; }
- }
-
- public override string IdentitySelectStatement(string tableName) {
- return tableName == null ? "select @@identity" : "select IDENT_CURRENT('" + tableName + "')";
- }
-
- public override Dictionary GetAllProcedureParameters(string procName)
- {
- return ReadIntoParams(procName,
-@" select c.name column_name
- , t.name type_name
- , c.length
- , c.status2
- , c.prec
- , c.scale
- from sysobjects o
- join syscolumns c on o.id = c.id
- join systypes t on t.usertype = c.usertype
- where o.type = 'P'
- and o.name=@objname
- ");
- }
-
- public override Dictionary GetAllColumns(string tableOrViewName)
- {
- return ReadIntoParams(tableOrViewName,
-@" select c.name column_name
- , t.name type_name
- , c.length
- , c.status2
- , c.prec
- , c.scale
- from sysobjects o
- join syscolumns c on o.id = c.id
- join systypes t on t.usertype = c.usertype
- where o.type in ('U','V')
- and o.name=@objname
- ");
- }
-
- public override bool SupportsReturnOnInsert
- {
- get { return false;}
- }
-
-
- public override int GetExceptionCode(Exception dbException)
- {
-
- if (dbException is Sybase.Data.AseClient.AseException)
- {
- AseException ae = dbException as AseException;
- if (ae.Errors != null)
- {
- AseError aseError = ae.Errors[0];
- Console.WriteLine("Sybase Exception code" + aseError.MessageNumber);
- return aseError.MessageNumber;
- }
- }
-
- return base.GetExceptionCode(dbException);
- }
-
- private Dictionary ReadIntoParams(String objname, String query)
- {
- if (objname.Contains("."))
- {
- String[] schemaAndName = objname.Split(new char[] { '.' }, 2);
- objname = schemaAndName[0] + ".." + schemaAndName[1] ;
- }
- else
- {
- objname = NameNormaliser.NormaliseName(objname) ;
- }
- var cnx = CurrentConnection;
- var dc = cnx.CreateCommand();
- dc.Transaction = (DbTransaction)CurrentTransaction;
- dc.CommandText = query;
- dc.CommandType = CommandType.Text;
- AddInput(dc, "@objname", objname);
- var reader = dc.ExecuteReader();
- Dictionary allParams = new Dictionary();
- int position = 0;
- while (reader.Read())
- {
-
- String paramName = (reader.IsDBNull(0)) ? null : reader.GetString(0);
- String dataType = reader.GetString(1);
- int length = (reader.IsDBNull(2)) ? 0 : System.Convert.ToInt32(reader[2]);
- int isOutput = (reader.IsDBNull(3)) ? 0 : System.Convert.ToInt32(reader[3]);
- byte precision = (reader.IsDBNull(4)) ? Convert.ToByte(0) : System.Convert.ToByte(reader[4]);
- byte scale = (reader.IsDBNull(5)) ? Convert.ToByte(0) : System.Convert.ToByte(reader[5]);
-
- AseParameter dp = new AseParameter();
- dp.Direction = GetParameterDirection(isOutput);
- if (!String.IsNullOrEmpty(paramName))
- {
- if (!paramName.StartsWith(ParameterPrefix))
- dp.ParameterName = ParameterPrefix + paramName;
- else
- dp.ParameterName = paramName;
- dp.SourceColumn = paramName;
- }
- else
- {
- dp.Direction = ParameterDirection.ReturnValue;
- }
- dp.AseDbType = GetDBType(dataType);
- String typeName = NormaliseTypeName(dataType);
- if (precision > 0) dp.Precision = precision;
- if (scale > 0) dp.Scale = scale;
- if ("NTEXT".Equals(typeName) || ("TEXT".Equals(typeName)))
- dp.Size = MAX_STRING_SIZE;
- else if (length > 0)
- {
- dp.Size = System.Convert.ToInt32(length);
- }
- else
- {
- if (!ParameterDirection.Input.Equals(dp.Direction) ||
- typeof(String).Equals(GetDotNetType(dataType)))
- dp.Size = MAX_STRING_SIZE;
- }
- allParams[NameNormaliser.NormaliseName(paramName)] = new DbParameterAccessor(dp, GetDotNetType(dataType), position++, dataType);
- }
- reader.Close();
- return allParams;
- }
-
- private static ParameterDirection GetParameterDirection(int isOutput)
- {
- if (isOutput == 2) return ParameterDirection.Output;
- else return ParameterDirection.Input;
- }
-
- private static string[] StringTypes = new string[] { "VARCHAR", "NVARCHAR", "CHAR", "NCHAR", "TEXT", "NTEXT", "XML" };
- private static string[] DecimalTypes = new string[] { "DECIMAL", "NUMERIC", "MONEY", "SMALLMONEY" };
- private static string[] DateTypes = new string[] { "SMALLDATETIME", "DATETIME", "TIMESTAMP" };
- private static string[] RefCursorTypes = new string[] { "REF" };
- private static string[] Int32Types = new string[] { "INT" };
- private static string[] Int16Types = new string[] { "TINYINT", "SMALLINT" };
- private static string[] Int64Types = new string[] { "BIGINT" };
-
- private static string[] BooleanTypes = new string[] { "BIT" };
- private static string[] BinaryTypes = new string[] { "BINARY", "VARBINARY", "IMAGE" };
- private static string[] GuidTypes = new string[] { "UNIQUEIDENTIFIER" };
- private static string[] VariantTypes = new string[] { "SQL_VARIANT" };
- private static string[] FloatTypes = new String[] { "REAL", "FLOAT" };
- private static string NormaliseTypeName(string dataType)
- {
- dataType = dataType.ToUpper().Trim();
- int idx = dataType.IndexOf(" ");
- if (idx >= 0) dataType = dataType.Substring(0, idx);
- idx = dataType.IndexOf("(");
- if (idx >= 0) dataType = dataType.Substring(0, idx);
- return dataType;
-
- }
- protected static AseDbType GetDBType(String dataType)
- {
- //todo:strip everything from first blank
- dataType = NormaliseTypeName(dataType);
-
- if (Array.IndexOf(StringTypes, dataType) >= 0) return AseDbType.VarChar;
- if (Array.IndexOf(DecimalTypes, dataType) >= 0) return AseDbType.Decimal;
- if (Array.IndexOf(DateTypes, dataType) >= 0) return AseDbType.DateTime;
- if (Array.IndexOf(Int32Types, dataType) >= 0) return AseDbType.Integer;
- if (Array.IndexOf(Int16Types, dataType) >= 0) return AseDbType.Integer;
- if (Array.IndexOf(Int64Types, dataType) >= 0) return AseDbType.Integer;
- if (Array.IndexOf(BooleanTypes, dataType) >= 0) return AseDbType.Bit;
- if (Array.IndexOf(BinaryTypes, dataType) >= 0) return AseDbType.VarBinary;
- //if (Array.IndexOf(RefCursorTypes, dataType) >= 0) return OracleType.Cursor;
- if (Array.IndexOf(GuidTypes, dataType) >= 0) return AseDbType.VarChar;
- if (Array.IndexOf(VariantTypes, dataType) >= 0) return AseDbType.VarChar;
- if (Array.IndexOf(FloatTypes, dataType) >= 0) return AseDbType.Decimal;
-
- throw new NotSupportedException("Type " + dataType + " is not supported");
- }
- protected static Type GetDotNetType(String dataType)
- {
- dataType = NormaliseTypeName(dataType);
- if (Array.IndexOf(StringTypes, dataType) >= 0) return typeof(string);
- if (Array.IndexOf(DecimalTypes, dataType) >= 0) return typeof(decimal);
- if (Array.IndexOf(Int32Types, dataType) >= 0) return typeof(Int32);
- if (Array.IndexOf(Int16Types, dataType) >= 0) return typeof(Int16);
- if (Array.IndexOf(Int64Types, dataType) >= 0) return typeof(Int64);
- if (Array.IndexOf(DateTypes, dataType) >= 0) return typeof(DateTime);
- if (Array.IndexOf(RefCursorTypes, dataType) >= 0) return typeof(DataTable);
- if (Array.IndexOf(BooleanTypes, dataType) >= 0) return typeof(bool);
- if (Array.IndexOf(BinaryTypes, dataType) >= 0) return typeof(byte[]);
- // if (Array.IndexOf(GuidTypes, dataType) >= 0) return typeof(System.Guid);
- if (Array.IndexOf(GuidTypes, dataType) >= 0) return typeof(string);
- if (Array.IndexOf(VariantTypes, dataType) >= 0) return typeof(string);
- if (Array.IndexOf(FloatTypes, dataType) >= 0) return typeof(double);
-
- throw new NotSupportedException("Type " + dataType + " is not supported");
- }
-
-
-
-
- }
-}
diff --git a/source/dbfitSybase/SybaseTest.cs b/source/dbfitSybase/SybaseTest.cs
deleted file mode 100644
index 4d829fcb..00000000
--- a/source/dbfitSybase/SybaseTest.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace dbfit
-{
- public class SybaseTest: DatabaseTest
- {
- public SybaseTest()
- : base(new SybaseEnvironment())
- {
-
- }
- }
-}
\ No newline at end of file
diff --git a/source/dbfitSybase/dbfitSybase.csproj b/source/dbfitSybase/dbfitSybase.csproj
deleted file mode 100644
index c8f00f8e..00000000
--- a/source/dbfitSybase/dbfitSybase.csproj
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
- net48;net8.0;net8.0-windows;net9.0;net9.0-windows
- dbfit.Sybase
- dbfit.Sybase
- false
- false
-
-
-
-
-
-
-
-
-
-
- ..\..\binary\tools\sybase\Sybase.AdoNet2.AseClient.dll
-
-
-
-
\ No newline at end of file
diff --git a/source/dbfitTest/DbConnectionPropertiesTest.cs b/source/dbfitTest/DbConnectionPropertiesTest.cs
deleted file mode 100644
index 196c011b..00000000
--- a/source/dbfitTest/DbConnectionPropertiesTest.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using NUnit.Framework;
-using NUnit.Framework.Legacy;
-
-namespace dbfit.util
-{
- [TestFixture]
-
- public class DbConnectionPropertiesTest
- {
- [Test]
- public void TestWithConnectionString()
- {
- DbConnectionProperties props=DbConnectionProperties.CreateFromString(
- @"connection-string=test1234");
- ClassicAssert.AreEqual("test1234", props.FullConnectionString);
- ClassicAssert.IsNull(props.Username);
- ClassicAssert.IsNull(props.Password);
- ClassicAssert.IsNull(props.Service);
- ClassicAssert.IsNull(props.DbName);
- }
- [Test]
- public void TestWithConnectionStringWithEquals()
- {
- DbConnectionProperties props = DbConnectionProperties.CreateFromString(
- @"connection-string=test1234&Username=US&Password=PW");
- ClassicAssert.AreEqual("test1234&Username=US&Password=PW", props.FullConnectionString);
- ClassicAssert.IsNull(props.Username);
- ClassicAssert.IsNull(props.Password);
- ClassicAssert.IsNull(props.Service);
- ClassicAssert.IsNull(props.DbName);
- }
- [Test]
- public void TestWithSplitProperties()
- {
- DbConnectionProperties props = DbConnectionProperties.CreateFromString(
- @"service=testsvc
- username=testuser
- password=testpwd
- database=testdb");
- ClassicAssert.IsNull(props.FullConnectionString);
- ClassicAssert.AreEqual("testuser",props.Username);
- ClassicAssert.AreEqual("testpwd",props.Password);
- ClassicAssert.AreEqual("testsvc",props.Service);
- ClassicAssert.AreEqual("testdb",props.DbName);
- }
- [Test]
- public void TestCommentsAndEmptyLines()
- {
- DbConnectionProperties props = DbConnectionProperties.CreateFromString(
- @"service=testsvc
-
- username=testuser
- password=testpwd
- #this is a comment
- database=testdb
- ");
- ClassicAssert.IsNull(props.FullConnectionString);
- ClassicAssert.AreEqual("testuser", props.Username);
- ClassicAssert.AreEqual("testpwd", props.Password);
- ClassicAssert.AreEqual("testsvc", props.Service);
- ClassicAssert.AreEqual("testdb", props.DbName);
- }
-
- }
-}
diff --git a/source/dbfitTest/ExecuteProcedureTest.cs b/source/dbfitTest/ExecuteProcedureTest.cs
deleted file mode 100644
index 6a944c01..00000000
--- a/source/dbfitTest/ExecuteProcedureTest.cs
+++ /dev/null
@@ -1,204 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Data;
-using System.Data.Common;
-using System.Data.SqlClient;
-using dbfit;
-using dbfit.fixture;
-using fit;
-using fit.Service;
-using Moq;
-using NUnit.Framework;
-using NUnit.Framework.Legacy;
-using TestStatus=fitSharp.Fit.Model.TestStatus;
-
-namespace dbfitTest {
- [TestFixture] public class ExecuteProcedureTest {
- private ExecuteProcedure fixture;
- private Mock db;
-
- [SetUp] public void SetUp() {
- db = new Mock();
- fixture = new ExecuteProcedure(db.Object, "myproc") {Processor = new Service()};
- }
-
- [Test]
- public void SortAccessorsInRightOrder()
- {
- //Prepare
- var accessorsToOrder = new DbParameterAccessor[4];
- accessorsToOrder[0]=new DbParameterAccessor(new SqlParameter(), typeof(string), 1, "String");
- accessorsToOrder[3]=new DbParameterAccessor(new SqlParameter(), typeof(string), 3, "String");
- accessorsToOrder[2]=new DbParameterAccessor(new SqlParameter(), typeof(string), 5, "String");
- accessorsToOrder[1]=new DbParameterAccessor(new SqlParameter(), typeof(string), 7, "String");
-
- //Execute
- DbParameterAccessor[] resultingAccessors = ExecuteProcedure.SortAccessors(accessorsToOrder);
-
- //Verify
- ClassicAssert.AreEqual(1, resultingAccessors[0].Position);
- ClassicAssert.AreEqual(3, resultingAccessors[1].Position);
- ClassicAssert.AreEqual(5, resultingAccessors[2].Position);
- ClassicAssert.AreEqual(7, resultingAccessors[3].Position);
- }
- [Test] public void ExecutesProcedureWithNoParameters() {
- var command = new TestCommand();
- RunTest(command, null, string.Empty);
- ClassicAssert.AreEqual(1, command.ExecuteNonQueryCalls);
- }
-
- [Test] public void ExecutesProcedureWithInputParameter() {
- var command = new TestCommand {
- NonQueryAction = (c => ClassicAssert.AreEqual("invalue", c.Parameters[0].Value))
- };
-
- RunTest(command, MakeParameters("inparm", ParameterDirection.Input),
- "inparm | invalue | ");
-
- ClassicAssert.AreEqual(1, command.ExecuteNonQueryCalls);
- }
-
- [Test] public void ExecutesProcedureWithOutputParameter() {
- var command = new TestCommand {
- NonQueryAction = (c => c.Parameters[0].Value = "outvalue")
- };
-
- RunTest(command, MakeParameters("outparm", ParameterDirection.Output),
- "outparm? | outvalue | ");
-
- ClassicAssert.AreEqual(1, command.ExecuteNonQueryCalls);
- ClassicAssert.AreEqual(1, fixture.TestStatus.Counts.GetCount(TestStatus.Right));
- }
-
- [Test] public void ExecutesProcedureWithInOutParameter() {
- var command = new TestCommand {
- NonQueryAction = (c => {
- ClassicAssert.AreEqual("invalue", c.Parameters[0].Value);
- c.Parameters[0].Value = "outvalue";
- })
- };
-
- RunTest(command, MakeParameters("ioparm", ParameterDirection.InputOutput),
- "ioparm | ioparm? | invalue | outvalue | ");
-
- ClassicAssert.AreEqual(1, command.ExecuteNonQueryCalls);
- ClassicAssert.AreEqual(1, fixture.TestStatus.Counts.GetCount(TestStatus.Right));
- }
-
- [Test] public void MarksWrongIfNoExpectedException() {
- fixture = new ExecuteProcedure(db.Object, "myproc", true) {Processor = new Service()};
- var command = new TestCommand();
-
- RunTest(command, MakeParameters("inparm", ParameterDirection.Input),
- "inparm | invalue | ");
-
- ClassicAssert.AreEqual(1, command.ExecuteNonQueryCalls);
- ClassicAssert.AreEqual(1, fixture.TestStatus.Counts.GetCount(TestStatus.Wrong));
- }
-
- [Test] public void MarksRightIfExpectedException() {
- fixture = new ExecuteProcedure(db.Object, "myproc", true) {Processor = new Service()};
- var command = new TestCommand {
- NonQueryAction = (c => { throw new ApplicationException();})
- };
-
- RunTest(command, MakeParameters("inparm", ParameterDirection.Input),
- "inparm | invalue | ");
-
- ClassicAssert.AreEqual(1, command.ExecuteNonQueryCalls);
- ClassicAssert.AreEqual(1, fixture.TestStatus.Counts.GetCount(TestStatus.Right));
- }
-
- private static Dictionary MakeParameters(string parameterName, ParameterDirection direction) {
- var parameter = new SqlParameter(parameterName, SqlDbType.VarChar, 10) {Direction = direction};
- return new Dictionary
- {{parameterName, new DbParameterAccessor(parameter, typeof (string), 0, "varchar")}};
- }
-
- private void RunTest(DbCommand command, Dictionary parameters, string html) {
- db.Setup(d => d.CreateCommand("myproc", CommandType.StoredProcedure))
- .Returns(command);
- db.Setup(d => d.GetAllProcedureParameters("myproc"))
- .Returns(parameters);
- Parse table = Parse.ParseFrom(string.Format("executeprocedure | myproc | {0} ", html));
- fixture.DoTable(table);
- }
- }
-
- public class TestCommand: DbCommand {
- public readonly SqlCommand Command = new SqlCommand();
- public int ExecuteNonQueryCalls;
- public Action NonQueryAction;
-
- public override void Prepare() {
- throw new NotImplementedException();
- }
-
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override string CommandText {
- get { throw new NotImplementedException(); }
- set { throw new NotImplementedException(); }
- }
-
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override int CommandTimeout {
- get { throw new NotImplementedException(); }
- set { throw new NotImplementedException(); }
- }
-
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override CommandType CommandType {
- get { throw new NotImplementedException(); }
- set { throw new NotImplementedException(); }
- }
-
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override UpdateRowSource UpdatedRowSource {
- get { throw new NotImplementedException(); }
- set { throw new NotImplementedException(); }
- }
-
- protected override DbConnection DbConnection {
- get { throw new NotImplementedException(); }
- set { throw new NotImplementedException(); }
- }
-
- protected override DbParameterCollection DbParameterCollection {
- get { return Command.Parameters; }
- }
-
- protected override DbTransaction DbTransaction {
- get { throw new NotImplementedException(); }
- set { throw new NotImplementedException(); }
- }
-
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
- public override bool DesignTimeVisible {
- get { throw new NotImplementedException(); }
- set { throw new NotImplementedException(); }
- }
-
- public override void Cancel() {
- throw new NotImplementedException();
- }
-
- protected override DbParameter CreateDbParameter() {
- throw new NotImplementedException();
- }
-
- protected override DbDataReader ExecuteDbDataReader(CommandBehavior behavior) {
- throw new NotImplementedException();
- }
-
- public override int ExecuteNonQuery() {
- ExecuteNonQueryCalls++;
- if (NonQueryAction != null) NonQueryAction(this);
- return 0;
- }
-
- public override object ExecuteScalar() {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/source/dbfitTest/NameNormaliserTest.cs b/source/dbfitTest/NameNormaliserTest.cs
deleted file mode 100644
index 5e333c64..00000000
--- a/source/dbfitTest/NameNormaliserTest.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-using dbfit.util;
-using NUnit.Framework;
-using NUnit.Framework.Legacy;
-
-namespace dbfit {
- [TestFixture]
- public class NameNormaliserTest {
-
- [Test]
- public void CheckNormaliseName() {
- ClassicAssert.AreEqual("dbtest", NameNormaliser.NormaliseName("dbtest?"));
- ClassicAssert.AreEqual("dbtest", NameNormaliser.NormaliseName("db test"));
- ClassicAssert.AreEqual("dbtest", NameNormaliser.NormaliseName("db test?"));
- ClassicAssert.AreEqual("db.test", NameNormaliser.NormaliseName("db.test"));
- ClassicAssert.AreEqual("db_test", NameNormaliser.NormaliseName("db_test"));
- ClassicAssert.AreEqual("dbtest", NameNormaliser.NormaliseName("DbTeSt"));
- }
- }
-}
diff --git a/source/dbfitTest/OracleEnvironmentTest.cs b/source/dbfitTest/OracleEnvironmentTest.cs
deleted file mode 100644
index 87ddd00c..00000000
--- a/source/dbfitTest/OracleEnvironmentTest.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using NUnit.Framework;
-using NUnit.Framework.Legacy;
-
-namespace dbfit {
- [TestFixture]
- public class OracleEnvironmentTest {
- private OracleEnvironment oe=new OracleEnvironment();
- [Test]
- public void CheckEmptyParams() {
- ClassicAssert.AreEqual(0,oe.ExtractParamNames("select * from dual").Length);
- }
- [Test]
- public void CheckSingleParam() {
- ClassicAssert.AreEqual(new string[]{"mydate"}, oe.ExtractParamNames("select * from dual where sysdate<:mydate"));
- }
- [Test]
- public void CheckMultipleParams() {
- string[] paramnames=oe.ExtractParamNames("select :myname as zeka from dual where sysdate<:mydate");
- ClassicAssert.AreEqual(2,paramnames.Length);
- ClassicAssert.Contains("mydate", paramnames);
- ClassicAssert.Contains("myname", paramnames);
- }
- [Test]
- public void CheckMultipleParamsRecurring() {
- string[] paramnames = oe.ExtractParamNames("select :myname,length(:myname) as l, :myname || :mydate as zeka2 from dual where sysdate<:mydate");
- ClassicAssert.AreEqual(2, paramnames.Length);
- ClassicAssert.Contains("mydate", paramnames);
- ClassicAssert.Contains("myname", paramnames);
- }
- [Test]
- public void CheckUnderscore() {
- ClassicAssert.AreEqual(new string[] { "my_date" }, oe.ExtractParamNames("select * from dual where sysdate<:my_date"));
- }
- }
-}
diff --git a/source/dbfitTest/Properties/AssemblyInfo.cs b/source/dbfitTest/Properties/AssemblyInfo.cs
deleted file mode 100644
index 54b0319a..00000000
--- a/source/dbfitTest/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-[assembly: AssemblyTitle("DbFit tests for fitSharp")]
-[assembly: AssemblyDescription("DbFit. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.")]
-[assembly: AssemblyProduct("fitSharp")]
-[assembly: ComVisible(false)]
-
-[assembly: AssemblyCopyright("Copyright © 2007 Gojko Adzic, 2022 Syterra Software Inc. All rights reserved.")]
-[assembly: AssemblyVersion("2022.1.15.0")]
diff --git a/source/dbfitTest/QueryTest.cs b/source/dbfitTest/QueryTest.cs
deleted file mode 100644
index 623bf825..00000000
--- a/source/dbfitTest/QueryTest.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright © 2016 Syterra Software Inc. All rights reserved.
-// The use and distribution terms for this software are covered by the Common Public License 1.0 (http://opensource.org/licenses/cpl.php)
-// which can be found in the file license.txt at the root of this distribution. By using this software in any fashion, you are agreeing
-// to be bound by the terms of this license. You must not remove this notice, or any other, from this software.
-
-using System.Data;
-using dbfit.fixture;
-using fit;
-using fit.Service;
-using fitSharp.Machine.Model;
-using NUnit.Framework;
-using NUnit.Framework.Legacy;
-using TestStatus=fitSharp.Fit.Model.TestStatus;
-
-namespace dbfitTest {
- [TestFixture]
- public class QueryTest {
- [Test]
- public void AccessesColumnWithQuotedUnderscore() {
- AssertQuery("some_column", "\"some_column\"");
- }
-
- [Test]
- public void AccessesColumnWithQuestionMark() {
- AssertQuery("somecolumn", "somecolumn?");
- }
-
- [Test]
- public void AccessesColumnWithWithQuotedUnderscoreAndQuestionMark() {
- AssertQuery("some_column", "\"some_column\"?");
- }
-
- private static void AssertQuery(string columnName, string headerCellName) {
- var dataTable = new DataTable();
- dataTable.Columns.Add("somekey", typeof (string));
- dataTable.Columns.Add(columnName, typeof (string));
- var newRow = dataTable.NewRow();
- newRow["somekey"] = "key";
- newRow[columnName] = "value";
- dataTable.Rows.Add(newRow);
- var fixture = new Query(dataTable, false) {Processor = new Service()};
-
- var testTable = new CellTree(
- new CellTree("query"),
- new CellTree("somekey", headerCellName),
- new CellTree("key", "value")
- );
- Parse parseTable = Parse.CopyFrom(testTable);
- fixture.DoTable(parseTable);
- ClassicAssert.AreEqual(TestStatus.Right, parseTable.At(0, 2, 0).GetAttribute(CellAttribute.Status));
- ClassicAssert.AreEqual(TestStatus.Right, parseTable.At(0, 2, 1).GetAttribute(CellAttribute.Status));
- }
- }
-}
diff --git a/source/dbfitTest/SqlServerEnvironmentTest.cs b/source/dbfitTest/SqlServerEnvironmentTest.cs
deleted file mode 100644
index b117ae19..00000000
--- a/source/dbfitTest/SqlServerEnvironmentTest.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright � 2012 Syterra Software Inc.
-// This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2.
-// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-
-using System.Data.Common;
-using dbfit;
-using NUnit.Framework;
-using NUnit.Framework.Legacy;
-
-namespace dbfitTest {
- [TestFixture] public class SqlServerEnvironmentTest {
- [Test] public void BuildsInsertCommand() {
- var environment = new SqlServerEnvironment();
- var parameterA = MakeParameter(environment, "aColumn", "aParameter");
- var parameterB = MakeParameter(environment, "bColumn", "bParameter");
- var command = environment.BuildInsertCommand(
- "aTable",
- new[] {
- new DbParameterAccessor(parameterA, typeof(string), 0, "varchar"),
- new DbParameterAccessor(parameterB, typeof(int), 1, "integer")
- });
- ClassicAssert.AreEqual("insert into aTable([aColumn],[bColumn]) values (@aParameter,@bParameter)", command);
- }
-
- static DbParameter MakeParameter(SqlServerEnvironment environment, string sourceColumn, string parameterName) {
- var parameterA = environment.DbProviderFactory.CreateParameter();
- parameterA.SourceColumn = sourceColumn;
- parameterA.ParameterName = parameterName;
- return parameterA;
- }
-
- [Test] public void BuildUpdateCommand() {
- var environment = new SqlServerEnvironment();
- var parameterA = MakeParameter(environment, "aColumn", "aParameter");
- var parameterB = MakeParameter(environment, "bColumn", "bParameter");
- var parameterC = MakeParameter(environment, "cColumn", "cParameter");
- var parameterD = MakeParameter(environment, "dColumn", "dParameter");
- var command = environment.BuildUpdateCommand(
- "aTable",
- new [] {
- new DbParameterAccessor(parameterA, typeof(string), 0, "varchar"),
- new DbParameterAccessor(parameterB, typeof(int), 1, "integer")
- },
- new[] {
- new DbParameterAccessor(parameterC, typeof(string), 2, "varchar"),
- new DbParameterAccessor(parameterD, typeof(int), 3, "integer")
- });
- ClassicAssert.AreEqual("update aTable set [aColumn]=@aParameter, [bColumn]=@bParameter where [cColumn]=@cParameter and [dColumn]=@dParameter", command);
- }
- }
-}
diff --git a/source/dbfitTest/acceptancescripts-MySql.sql b/source/dbfitTest/acceptancescripts-MySql.sql
deleted file mode 100644
index 455e2e1f..00000000
--- a/source/dbfitTest/acceptancescripts-MySql.sql
+++ /dev/null
@@ -1,31 +0,0 @@
-create database dbfit;
-
-grant all privileges on dbfit.* to dftest@localhost identified by 'dftest';
-
-grant all privileges on dbfit.* to dftest@127.0.0.1 identified by 'dftest';
-
-grant all privileges on dbfit.* to dbfit_user@localhost identified by 'password';
-
-grant all privileges on dbfit.* to dbfit_user@127.0.0.1 identified by 'password';
-
-grant select on mysql.* to dbfit_user@localhost;
-
-flush privileges;
-
-use dbfit;
-
-create table users(name varchar(50) unique, username varchar(50), userid int auto_increment primary key);
-
-CREATE PROCEDURE ConcatenateStrings (IN firststring varchar(100), IN secondstring varchar(100), OUT concatenated varchar(200)) set concatenated = concat(firststring , concat( ' ' , secondstring ));
-
-create procedure CalcLength(IN name varchar(100), OUT strlength int) set strlength =length(name);
-
-CREATE FUNCTION ConcatenateF (firststring VARCHAR(100), secondstring varchar(100)) RETURNS VARCHAR(200) RETURN CONCAT(firststring,' ',secondstring);
-
-create procedure makeuser() insert into users (name,username) values ('user1','fromproc');
-
-create procedure createuser(IN newname varchar(100), IN newusername varchar(100)) insert into users (name,username) values (newname, newusername);
-
-create procedure Multiply(IN factor int, INOUT val int) set val =val*factor;
-
-Create table Test_DBFit(name varchar(50), luckyNumber int) engine=InnoDB;
diff --git a/source/dbfitTest/acceptancescripts-SqlServer.sql b/source/dbfitTest/acceptancescripts-SqlServer.sql
deleted file mode 100644
index cdc99641..00000000
--- a/source/dbfitTest/acceptancescripts-SqlServer.sql
+++ /dev/null
@@ -1,233 +0,0 @@
-SET ANSI_NULLS ON
-GO
-SET QUOTED_IDENTIFIER ON
-GO
-IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Multiply]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
-BEGIN
-execute dbo.sp_executesql @statement = N' create function [dbo].[Multiply](@n1 int, @n2 int) returns int as begin declare @num3 int; set @num3 = @n1*@n2; return @num3; end; '
-END
-
-GO
-SET ANSI_NULLS ON
-GO
-SET QUOTED_IDENTIFIER ON
-GO
-IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CalcLength_P]') AND type in (N'P', N'PC'))
-BEGIN
-EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[CalcLength_P]
-@name VARCHAR(255)
-, @strlength INT OUTPUT
-AS
-BEGIN
- SET @strlength = DataLength(@name);
-END;
-'
-END
-GO
-SET ANSI_NULLS ON
-GO
-SET QUOTED_IDENTIFIER ON
-GO
-IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ReturnUserTable_F]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
-BEGIN
-execute dbo.sp_executesql @statement = N'-- =============================================
--- Author:
--- Create date:
--- Description:
--- =============================================
-CREATE FUNCTION [dbo].[ReturnUserTable_F]
-(
- @howmuch int
-)
-RETURNS
-@userTable TABLE
-(
- -- Add the column definitions for the TABLE variable here
- [user] varchar(50),
- [username] varchar(255)
-)
-AS
-BEGIN
- -- Fill the table variable with the rows for your result set
- DECLARE @i INT
- SET @i = 0
- WHILE (@i < @howmuch)
- BEGIN
- SET @i = @i + 1
- INSERT @userTable([user], [username])
- VALUES(''User '' + CAST(@i AS VARCHAR(10)), ''Username '' + CAST(@i AS VARCHAR(10)))
- END
-
- RETURN
-END
-'
-END
-
-GO
-SET ANSI_NULLS ON
-GO
-SET QUOTED_IDENTIFIER ON
-GO
-IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ConcatenateStrings_P]') AND type in (N'P', N'PC'))
-BEGIN
-EXEC dbo.sp_executesql @statement = N'
-CREATE PROCEDURE [dbo].[ConcatenateStrings_P]
-@firstString varchar(255)
-,@secondString varchar(255)
-,@concatenated varchar(600) output
-AS
-BEGIN
- SET @concatenated = @firstString + '' '' + @secondString
-END
-'
-END
-GO
-SET ANSI_NULLS ON
-GO
-SET QUOTED_IDENTIFIER ON
-GO
-IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ConcatenateStrings_F]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
-BEGIN
-execute dbo.sp_executesql @statement = N'
-CREATE FUNCTION [dbo].[ConcatenateStrings_F]
-(
-@firstString varchar(255)
-,@secondString varchar(255)
-)
-RETURNS VARCHAR(600)
-AS
-BEGIN
- DECLARE @concatenated VARCHAR(600)
- SET @concatenated = @firstString + '' '' + @secondString
- RETURN @concatenated
-END
-'
-END
-
-GO
-SET ANSI_NULLS ON
-GO
-SET QUOTED_IDENTIFIER ON
-GO
-IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[Users]') AND type in (N'U'))
-BEGIN
-CREATE TABLE [dbo].[Users](
- [name] [varchar](50) NULL,
- [username] [varchar](50) NULL,
- [userid] [int] IDENTITY(1,1) NOT NULL
-) ON [PRIMARY]
-END
-GO
-SET ANSI_NULLS ON
-GO
-SET QUOTED_IDENTIFIER ON
-GO
-IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[PopulateUserTable_P]') AND type in (N'P', N'PC'))
-BEGIN
-EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[PopulateUserTable_P]
-@howmuch INT
-AS
-BEGIN
- -- Fill the table variable with the rows for your result set
- DECLARE @i INT
- SET @i = 0
- WHILE (@i < @howmuch)
- BEGIN
- SET @i = @i + 1
- INSERT [Users]([name], [username])
- VALUES(''User '' + CAST(@i AS VARCHAR(10)), ''Username '' + CAST(@i AS VARCHAR(10)))
- END
-END
-'
-END
-GO
-SET ANSI_NULLS ON
-GO
-SET QUOTED_IDENTIFIER ON
-GO
-IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[OpenCrsr_P]') AND type in (N'P', N'PC'))
-BEGIN
-EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[OpenCrsr_P]
-@howmuch INT,
-@OutCrsr CURSOR VARYING OUTPUT
-AS
-BEGIN
- SET @OutCrsr = CURSOR FOR
- SELECT TOP (@howmuch) [name], [username], [userid]
- FROM [Users];
-
- OPEN @OutCrsr;
-END
-'
-END
-GO
-SET ANSI_NULLS ON
-GO
-SET QUOTED_IDENTIFIER ON
-GO
-IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[DeleteUserTable_P]') AND type in (N'P', N'PC'))
-BEGIN
-EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[DeleteUserTable_P]
-AS
-DELETE [Users];
-'
-END
-GO
-
-CREATE PROCEDURE [dbo].[TestProc2]
- @iddocument int,
- @iddestination_user int
-as
-declare @errorsave int
-
-set @errorsave = 0
-
-if (@iddocument < 100)
-begin
- set @errorsave = 53120
- raiserror(@errorsave, 15, 1, 'Custom error message')
- return @errorsave
-end
-go
-
-exec sp_addmessage @msgnum = 53120, @severity=1, @msgtext = 'test user defined error msg'
-
-GO
-CREATE procedure [dbo].[ListUsers_P] @howmuch int AS
-BEGIN
-select top (@howmuch) * from users order by userid
-END;
-GO
-
-create procedure MultiplyIO(@factor int, @val int output) as
-begin
- set @val = @factor*@val;
-end;
-
-GO
-
-create procedure TestDecimal
-@inParam decimal(15, 8),
-@copyOfInParam decimal(15, 8) out,
-@constOutParam decimal(15, 8) out
-as
-begin
-set @copyOfInParam = @inParam
-set @constOutParam = 123.456;
-end;
-
-GO
-
-Create procedure TestReturn
-@inParam int
-as
-begin
- return @inParam
-end
-GO
-
-alter PROC up_vb
- @vb varbinary(16)
-as
- select cast(0x1020304050 as varbinary(16)) as d2
-GO
\ No newline at end of file
diff --git a/source/dbfitTest/dbfitTest.csproj b/source/dbfitTest/dbfitTest.csproj
deleted file mode 100644
index 7dc2dc83..00000000
--- a/source/dbfitTest/dbfitTest.csproj
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
- Library
- net48;net8.0;net8.0-windows;net9.0;net9.0-windows
- fitSharp.Test
- false
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/source/dbfitTest/packages.config b/source/dbfitTest/packages.config
deleted file mode 100644
index f132ab27..00000000
--- a/source/dbfitTest/packages.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
| |