diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..81d5a19e --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,6 @@ +{ + "recommendations": [ + "ms-dotnettools.csdevkit", + "ms-azuretools.vscode-docker" + ] +} diff --git a/PetaPoco.Tests.Integration/DataSources/PetaPoco.sqlite b/PetaPoco.Tests.Integration/DataSources/PetaPoco.sqlite deleted file mode 100644 index a45e68b8..00000000 Binary files a/PetaPoco.Tests.Integration/DataSources/PetaPoco.sqlite and /dev/null differ diff --git a/PetaPoco.Tests.Integration/DataSources/petapoco.accdb b/PetaPoco.Tests.Integration/DataSources/petapoco.accdb deleted file mode 100644 index 719de244..00000000 Binary files a/PetaPoco.Tests.Integration/DataSources/petapoco.accdb and /dev/null differ diff --git a/PetaPoco.Tests.Integration/Databases/BaseDatabase.cs b/PetaPoco.Tests.Integration/Databases/BaseDatabase.cs deleted file mode 100644 index 72aec4b4..00000000 --- a/PetaPoco.Tests.Integration/Databases/BaseDatabase.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System; - -namespace PetaPoco.Tests.Integration.Databases -{ - public abstract class BaseDatabase : IDisposable - { - private DBTestProvider _provider; - - protected IDatabase DB { get; set; } - protected string ProviderName { get; private set; } - - protected BaseDatabase(DBTestProvider provider) - { - _provider = provider; - DB = _provider.Execute(); - ProviderName = _provider.ProviderName; - } - - public void Dispose() - { - if (DB != null) - { - _provider.Dispose(); - _provider = null; - DB.Dispose(); - DB = null; - } - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/BaseDbContext.cs b/PetaPoco.Tests.Integration/Databases/BaseDbContext.cs new file mode 100644 index 00000000..77c55d03 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/BaseDbContext.cs @@ -0,0 +1,27 @@ +using System; + +namespace PetaPoco.Tests.Integration +{ + public abstract class BaseDbContext : IDisposable + { + private TestProvider _provider; + + protected IDatabase DB { get; set; } + protected string ProviderName { get; private set; } + + protected BaseDbContext(TestProvider provider) + { + _provider = provider; + DB = _provider.Execute(); + ProviderName = _provider.ProviderName; + } + + public void Dispose() + { + _provider?.Dispose(); + _provider = null; + DB?.Dispose(); + DB = null; + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/BaseTriageTests.cs b/PetaPoco.Tests.Integration/Databases/BaseTriageTests.cs deleted file mode 100644 index 8e792c26..00000000 --- a/PetaPoco.Tests.Integration/Databases/BaseTriageTests.cs +++ /dev/null @@ -1,14 +0,0 @@ -using PetaPoco.Tests.Integration.Models; -using Shouldly; -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases -{ - public abstract class BaseTriageTests : BaseDatabase - { - protected BaseTriageTests(DBTestProvider provider) - : base(provider) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/BaseDatabaseTests.cs b/PetaPoco.Tests.Integration/Databases/DatabaseTests.cs similarity index 98% rename from PetaPoco.Tests.Integration/Databases/BaseDatabaseTests.cs rename to PetaPoco.Tests.Integration/Databases/DatabaseTests.cs index bbf4d33d..3839f457 100644 --- a/PetaPoco.Tests.Integration/Databases/BaseDatabaseTests.cs +++ b/PetaPoco.Tests.Integration/Databases/DatabaseTests.cs @@ -8,9 +8,9 @@ using Shouldly; using Xunit; -namespace PetaPoco.Tests.Integration.Databases +namespace PetaPoco.Tests.Integration { - public abstract class BaseDatabaseTests : BaseDatabase + public abstract class DatabaseTests : BaseDbContext { // TODO: Move to base class, combine with other test data #region Test Data @@ -23,7 +23,7 @@ public abstract class BaseDatabaseTests : BaseDatabase #endregion - protected BaseDatabaseTests(DBTestProvider provider) + protected DatabaseTests(TestProvider provider) : base(provider) { } diff --git a/PetaPoco.Tests.Integration/Databases/BaseDeleteTests.cs b/PetaPoco.Tests.Integration/Databases/DeleteTests.cs similarity index 98% rename from PetaPoco.Tests.Integration/Databases/BaseDeleteTests.cs rename to PetaPoco.Tests.Integration/Databases/DeleteTests.cs index 04b8e0cc..b617fa7c 100644 --- a/PetaPoco.Tests.Integration/Databases/BaseDeleteTests.cs +++ b/PetaPoco.Tests.Integration/Databases/DeleteTests.cs @@ -4,9 +4,9 @@ using Shouldly; using Xunit; -namespace PetaPoco.Tests.Integration.Databases +namespace PetaPoco.Tests.Integration { - public abstract class BaseDeleteTests : BaseDatabase + public abstract class DeleteTests : BaseDbContext { // TODO: Move to base class, combine with other test data #region Test Data @@ -49,7 +49,7 @@ public abstract class BaseDeleteTests : BaseDatabase #endregion - protected BaseDeleteTests(DBTestProvider provider) + protected DeleteTests(TestProvider provider) : base(provider) { } diff --git a/PetaPoco.Tests.Integration/Databases/BaseExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/ExecuteTests.cs similarity index 96% rename from PetaPoco.Tests.Integration/Databases/BaseExecuteTests.cs rename to PetaPoco.Tests.Integration/Databases/ExecuteTests.cs index 4636f707..3d668e12 100644 --- a/PetaPoco.Tests.Integration/Databases/BaseExecuteTests.cs +++ b/PetaPoco.Tests.Integration/Databases/ExecuteTests.cs @@ -5,19 +5,14 @@ using Shouldly; using Xunit; -namespace PetaPoco.Tests.Integration.Databases +namespace PetaPoco.Tests.Integration { - public abstract class BaseExecuteTests : BaseDatabase + public abstract class ExecuteTests : BaseDbContext { - // TODO: Move to base class, combine with other test data - #region Test Data - // TODO: Make this a protected accessor from the base test class private readonly PocoData _pd; - #endregion - - protected BaseExecuteTests(DBTestProvider provider) + protected ExecuteTests(TestProvider provider) : base(provider) { _pd = PocoData.ForType(typeof(Note), DB.DefaultMapper); diff --git a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdDatabaseTests.cs b/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdDatabaseTests.cs deleted file mode 100644 index 0fd1d651..00000000 --- a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdDatabaseTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.Firebird -{ - [Collection("Firebird")] - public class FirebirdDatabaseTests : BaseDatabaseTests - { - public FirebirdDatabaseTests() - : base(new FirebirdDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdExecuteTests.cs deleted file mode 100644 index 10845a79..00000000 --- a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdExecuteTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.Firebird -{ - [Collection("Firebird")] - public class FirebirdExecuteTests : BaseExecuteTests - { - public FirebirdExecuteTests() - : base(new FirebirdDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdInsertTests.cs b/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdInsertTests.cs deleted file mode 100644 index e751262a..00000000 --- a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdInsertTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.Firebird -{ - [Collection("Firebird")] - public class FirebirdInsertTests : BaseInsertTests - { - public FirebirdInsertTests() - : base(new FirebirdDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdMiscellaneousTests.cs b/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdMiscellaneousTests.cs deleted file mode 100644 index a6b40649..00000000 --- a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdMiscellaneousTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.Firebird -{ - [Collection("Firebird")] - public class FirebirdMiscellaneousTests : BaseMiscellaneousTests - { - public FirebirdMiscellaneousTests() - : base(new FirebirdDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdQueryLinqTests.cs b/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdQueryLinqTests.cs deleted file mode 100644 index af5f9082..00000000 --- a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdQueryLinqTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.Firebird -{ - [Collection("Firebird")] - public class FirebirdQueryLinqTests : BaseQueryLinqTests - { - public FirebirdQueryLinqTests() - : base(new FirebirdDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdDatabaseTests.cs b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdDatabaseTests.cs new file mode 100644 index 00000000..98c8f903 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdDatabaseTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.Firebird +{ + [Collection("Firebird")] + public class FirebirdDatabaseTests : DatabaseTests + { + public FirebirdDatabaseTests() + : base(new FirebirdTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdDeleteTests.cs b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdDeleteTests.cs similarity index 54% rename from PetaPoco.Tests.Integration/Databases/Firebird/FirebirdDeleteTests.cs rename to PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdDeleteTests.cs index d37e867f..6e2aa508 100644 --- a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdDeleteTests.cs +++ b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdDeleteTests.cs @@ -1,13 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; using Xunit; namespace PetaPoco.Tests.Integration.Databases.Firebird { [Collection("Firebird")] - public class FirebirdDeleteTests : BaseDeleteTests + public class FirebirdDeleteTests : DeleteTests { public FirebirdDeleteTests() - : base(new FirebirdDBTestProvider()) + : base(new FirebirdTestProvider()) { } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdExecuteTests.cs new file mode 100644 index 00000000..baf0078a --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdExecuteTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.Firebird +{ + [Collection("Firebird")] + public class FirebirdExecuteTests : ExecuteTests + { + public FirebirdExecuteTests() + : base(new FirebirdTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdInsertTests.cs b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdInsertTests.cs new file mode 100644 index 00000000..a27fcbf4 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdInsertTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.Firebird +{ + [Collection("Firebird")] + public class FirebirdInsertTests : InsertTests + { + public FirebirdInsertTests() + : base(new FirebirdTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdMiscellaneousTests.cs b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdMiscellaneousTests.cs new file mode 100644 index 00000000..5a61852b --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdMiscellaneousTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.Firebird +{ + [Collection("Firebird")] + public class FirebirdMiscellaneousTests : MiscellaneousTests + { + public FirebirdMiscellaneousTests() + : base(new FirebirdTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdPreExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdPreExecuteTests.cs new file mode 100644 index 00000000..17b8f5b8 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdPreExecuteTests.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using System.Data; +using System.Linq; +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.Firebird +{ + [Collection("Firebird")] + public class FirebirdPreExecuteTests : PreExecuteTests + { + protected override IPreExecuteDatabaseProvider Provider => DB.Provider as PreExecuteDatabaseProvider; + + public FirebirdPreExecuteTests() + : base(new PreExecuteTestProvider()) + { + Provider.ThrowExceptions = true; + } + + protected class PreExecuteTestProvider : FirebirdTestProvider + { + protected override IDatabase LoadFromConnectionName(string name) + => BuildFromConnectionName(name).UsingProvider().Create(); + } + + protected class PreExecuteDatabaseProvider : PetaPoco.Providers.FirebirdDbDatabaseProvider, IPreExecuteDatabaseProvider + { + public bool ThrowExceptions { get; set; } + public List Parameters { get; set; } = new List(); + + public override void PreExecute(IDbCommand cmd) + { + Parameters.Clear(); + + if (ThrowExceptions) + { + Parameters = cmd.Parameters.Cast().ToList(); + throw new PreExecuteException(); + } + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdQueryLinqTests.cs b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdQueryLinqTests.cs new file mode 100644 index 00000000..6cd7c2e1 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdQueryLinqTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.Firebird +{ + [Collection("Firebird")] + public class FirebirdQueryLinqTests : QueryLinqTests + { + public FirebirdQueryLinqTests() + : base(new FirebirdTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdQueryTests.cs b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdQueryTests.cs similarity index 98% rename from PetaPoco.Tests.Integration/Databases/Firebird/FirebirdQueryTests.cs rename to PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdQueryTests.cs index a3315e67..44051682 100644 --- a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdQueryTests.cs +++ b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdQueryTests.cs @@ -3,16 +3,17 @@ using System.Linq; using PetaPoco.Core; using PetaPoco.Tests.Integration.Models; +using PetaPoco.Tests.Integration.Providers; using Shouldly; using Xunit; namespace PetaPoco.Tests.Integration.Databases.Firebird { [Collection("Firebird")] - public class FirebirdQueryTests : BaseQueryTests + public class FirebirdQueryTests : QueryTests { public FirebirdQueryTests() - : base(new FirebirdDBTestProvider()) + : base(new FirebirdTestProvider()) { } diff --git a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdStoredProcTests.cs b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdStoredProcTests.cs similarity index 66% rename from PetaPoco.Tests.Integration/Databases/Firebird/FirebirdStoredProcTests.cs rename to PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdStoredProcTests.cs index c4bf1cbf..f6ad2334 100644 --- a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdStoredProcTests.cs +++ b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdStoredProcTests.cs @@ -1,17 +1,18 @@ using System; using FirebirdSql.Data.FirebirdClient; +using PetaPoco.Tests.Integration.Providers; using Xunit; namespace PetaPoco.Tests.Integration.Databases.Firebird { [Collection("Firebird")] - public class FirebirdStoredProcTests : BaseStoredProcTests + public class FirebirdStoredProcTests : StoredProcTests { protected override Type DataParameterType => typeof(FbParameter); public FirebirdStoredProcTests() - : base(new FirebirdDBTestProvider()) + : base(new FirebirdTestProvider()) { } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdTriageTests.cs b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdTriageTests.cs similarity index 50% rename from PetaPoco.Tests.Integration/Databases/Firebird/FirebirdTriageTests.cs rename to PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdTriageTests.cs index 3121f608..679f65c6 100644 --- a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdTriageTests.cs +++ b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdTriageTests.cs @@ -1,12 +1,13 @@ -using Xunit; +using PetaPoco.Tests.Integration.Providers; +using Xunit; namespace PetaPoco.Tests.Integration.Databases.Firebird { [Collection("Firebird")] - public class FirebirdTriageTests : BaseTriageTests + public class FirebirdTriageTests : TriageTests { public FirebirdTriageTests() - : base(new FirebirdDBTestProvider()) + : base(new FirebirdTestProvider()) { } } diff --git a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdUpdateTests.cs b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdUpdateTests.cs similarity index 54% rename from PetaPoco.Tests.Integration/Databases/Firebird/FirebirdUpdateTests.cs rename to PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdUpdateTests.cs index 7de99aa2..f3e981bf 100644 --- a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdUpdateTests.cs +++ b/PetaPoco.Tests.Integration/Databases/FirebirdTests/FirebirdUpdateTests.cs @@ -1,13 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; using Xunit; namespace PetaPoco.Tests.Integration.Databases.Firebird { [Collection("Firebird")] - public class FirebirdUpdateTests : BaseUpdateTests + public class FirebirdUpdateTests : UpdateTests { public FirebirdUpdateTests() - : base(new FirebirdDBTestProvider()) + : base(new FirebirdTestProvider()) { } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Databases/BaseInsertTests.cs b/PetaPoco.Tests.Integration/Databases/InsertTests.cs similarity index 99% rename from PetaPoco.Tests.Integration/Databases/BaseInsertTests.cs rename to PetaPoco.Tests.Integration/Databases/InsertTests.cs index 1b7c190f..1f54efde 100644 --- a/PetaPoco.Tests.Integration/Databases/BaseInsertTests.cs +++ b/PetaPoco.Tests.Integration/Databases/InsertTests.cs @@ -4,9 +4,9 @@ using Shouldly; using Xunit; -namespace PetaPoco.Tests.Integration.Databases +namespace PetaPoco.Tests.Integration { - public abstract class BaseInsertTests : BaseDatabase + public abstract class InsertTests : BaseDbContext { // TODO: Move to base class, combine with other test data #region Test Data @@ -43,7 +43,7 @@ public abstract class BaseInsertTests : BaseDatabase #endregion - protected BaseInsertTests(DBTestProvider provider) + protected InsertTests(TestProvider provider) : base(provider) { } diff --git a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessDBTestProvider.cs b/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessDBTestProvider.cs deleted file mode 100644 index 9fe53432..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessDBTestProvider.cs +++ /dev/null @@ -1,36 +0,0 @@ -using System; -using System.Linq; - -namespace PetaPoco.Tests.Integration.Databases.MSAccess -{ - public class MsAccessDBTestProvider : DBTestProvider - { - protected override string ConnectionName => "msaccess"; - - protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.MSAccessBuildDatabase.sql"; - - public override void ExecuteBuildScript(IDatabase database, string script) - { - script.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToList().ForEach(s => - { - if (String.IsNullOrEmpty(s) || s.StartsWith("--")) - return; - - if (s.StartsWith("DROP")) - { - try - { - base.ExecuteBuildScript(database, s); - } - catch - { - } - - return; - } - - base.ExecuteBuildScript(database, s); - }); - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessDeleteTests.cs b/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessDeleteTests.cs deleted file mode 100644 index 696cf6f7..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessDeleteTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSAccess -{ - [Collection("MSAccess")] - public class MsAccessDeleteTests : BaseDeleteTests - { - public MsAccessDeleteTests() - : base(new MsAccessDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessExecuteTests.cs deleted file mode 100644 index b04599eb..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessExecuteTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSAccess -{ - [Collection("MSAccess")] - public class MsAccessExecuteTests : BaseExecuteTests - { - public MsAccessExecuteTests() - : base(new MsAccessDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessInsertTests.cs b/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessInsertTests.cs deleted file mode 100644 index ac0843be..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessInsertTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSAccess -{ - [Collection("MSAccess")] - public class MsAccessInsertTests : BaseInsertTests - { - public MsAccessInsertTests() - : base(new MsAccessDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessMiscellaneousTests.cs b/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessMiscellaneousTests.cs deleted file mode 100644 index 811849cc..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessMiscellaneousTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSAccess -{ - [Collection("MSAccess")] - public class MsAccessMiscellaneousTests : BaseMiscellaneousTests - { - public MsAccessMiscellaneousTests() - : base(new MsAccessDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessQueryLinqTests.cs b/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessQueryLinqTests.cs deleted file mode 100644 index 0648f258..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessQueryLinqTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSAccess -{ - [Collection("MSAccess")] - public class MsAccessQueryLinqTests : BaseQueryLinqTests - { - public MsAccessQueryLinqTests() - : base(new MsAccessDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessTriageTests.cs b/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessTriageTests.cs deleted file mode 100644 index eda7a108..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessTriageTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSAccess -{ - [Collection("MSAccess")] - public class MsAccessTriageTests : BaseTriageTests - { - public MsAccessTriageTests() - : base(new MsAccessDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessUpdateTests.cs b/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessUpdateTests.cs deleted file mode 100644 index e4517d7d..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessUpdateTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSAccess -{ - [Collection("MSAccess")] - public class MsAccessUpdateTests : BaseUpdateTests - { - public MsAccessUpdateTests() - : base(new MsAccessDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessDatabaseTests.cs b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessDatabaseTests.cs similarity index 59% rename from PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessDatabaseTests.cs rename to PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessDatabaseTests.cs index 796f0164..56cb47be 100644 --- a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessDatabaseTests.cs +++ b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessDatabaseTests.cs @@ -1,12 +1,13 @@ -using Xunit; +using PetaPoco.Tests.Integration.Providers; +using Xunit; namespace PetaPoco.Tests.Integration.Databases.MSAccess { [Collection("MSAccess")] - public class MsAccessDatabaseTests : BaseDatabaseTests + public class MSAccessDatabaseTests : DatabaseTests { - public MsAccessDatabaseTests() - : base(new MsAccessDBTestProvider()) + public MSAccessDatabaseTests() + : base(new MSAccessTestProvider()) { } diff --git a/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessDeleteTests.cs b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessDeleteTests.cs new file mode 100644 index 00000000..5cadf573 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessDeleteTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MSAccess +{ + [Collection("MSAccess")] + public class MSAccessDeleteTests : DeleteTests + { + public MSAccessDeleteTests() + : base(new MSAccessTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessExecuteTests.cs new file mode 100644 index 00000000..a7070604 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessExecuteTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MSAccess +{ + [Collection("MSAccess")] + public class MSAccessExecuteTests : ExecuteTests + { + public MSAccessExecuteTests() + : base(new MSAccessTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessInsertTests.cs b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessInsertTests.cs new file mode 100644 index 00000000..37cea6a8 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessInsertTests.cs @@ -0,0 +1,15 @@ +using Xunit; +using PetaPoco.Tests.Integration.Providers; + + +namespace PetaPoco.Tests.Integration.Databases.MSAccess +{ + [Collection("MSAccess")] + public class MSAccessInsertTests : InsertTests + { + public MSAccessInsertTests() + : base(new MSAccessTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessMiscellaneousTests.cs b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessMiscellaneousTests.cs new file mode 100644 index 00000000..9d503332 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessMiscellaneousTests.cs @@ -0,0 +1,15 @@ +using Xunit; +using PetaPoco.Tests.Integration.Providers; + + +namespace PetaPoco.Tests.Integration.Databases.MSAccess +{ + [Collection("MSAccess")] + public class MSAccessMiscellaneousTests : MiscellaneousTests + { + public MSAccessMiscellaneousTests() + : base(new MSAccessTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessPreExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessPreExecuteTests.cs new file mode 100644 index 00000000..82151076 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessPreExecuteTests.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using System.Data; +using System.Linq; +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MSAccess +{ + [Collection("MSAccess")] + public class MSAccessPreExecuteTests : PreExecuteTests + { + protected override IPreExecuteDatabaseProvider Provider => DB.Provider as PreExecuteDatabaseProvider; + + public MSAccessPreExecuteTests() + : base(new PreExecuteTestProvider()) + { + Provider.ThrowExceptions = true; + } + + protected class PreExecuteTestProvider : MSAccessTestProvider + { + protected override IDatabase LoadFromConnectionName(string name) + => BuildFromConnectionName(name).UsingProvider().Create(); + } + + protected class PreExecuteDatabaseProvider : PetaPoco.Providers.MsAccessDbDatabaseProvider, IPreExecuteDatabaseProvider + { + public bool ThrowExceptions { get; set; } + public List Parameters { get; set; } = new List(); + + public override void PreExecute(IDbCommand cmd) + { + Parameters.Clear(); + + if (ThrowExceptions) + { + Parameters = cmd.Parameters.Cast().ToList(); + throw new PreExecuteException(); + } + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessQueryLinqTests.cs b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessQueryLinqTests.cs new file mode 100644 index 00000000..b9d4ec4d --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessQueryLinqTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MSAccess +{ + [Collection("MSAccess")] + public class MSAccessQueryLinqTests : QueryLinqTests + { + public MSAccessQueryLinqTests() + : base(new MSAccessTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessQueryTests.cs b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessQueryTests.cs similarity index 99% rename from PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessQueryTests.cs rename to PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessQueryTests.cs index d0e5b742..4d2f1b82 100644 --- a/PetaPoco.Tests.Integration/Databases/MSAccess/MsAccessQueryTests.cs +++ b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessQueryTests.cs @@ -5,16 +5,17 @@ using PetaPoco.Core; using PetaPoco.Tests.Integration.Models; using PetaPoco.Tests.Integration.Models.MSAccess; +using PetaPoco.Tests.Integration.Providers; using Shouldly; using Xunit; namespace PetaPoco.Tests.Integration.Databases.MSAccess { [Collection("MSAccess")] - public class MsAccessQueryTests : BaseQueryTests + public class MSAccessQueryTests : QueryTests { - public MsAccessQueryTests() - : base(new MsAccessDBTestProvider()) + public MSAccessQueryTests() + : base(new MSAccessTestProvider()) { } diff --git a/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessTriageTests.cs b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessTriageTests.cs new file mode 100644 index 00000000..b2e629db --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessTriageTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MSAccess +{ + [Collection("MSAccess")] + public class MSAccessTriageTests : TriageTests + { + public MSAccessTriageTests() + : base(new MSAccessTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessUpdateTests.cs b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessUpdateTests.cs new file mode 100644 index 00000000..73489289 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MSAccessTests/MSAccessUpdateTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MSAccess +{ + [Collection("MSAccess")] + public class MSAccessUpdateTests : UpdateTests + { + public MSAccessUpdateTests() + : base(new MSAccessTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlDatabaseTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlDatabaseTests.cs deleted file mode 100644 index 649e03d1..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlDatabaseTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSSQL -{ - [Collection("Mssql")] - public class MssqlDatabaseTests : BaseDatabaseTests - { - public MssqlDatabaseTests() - : base(new MssqlDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlDeleteTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlDeleteTests.cs deleted file mode 100644 index 1f0bf284..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlDeleteTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSSQL -{ - [Collection("Mssql")] - public class MssqlDeleteTests : BaseDeleteTests - { - public MssqlDeleteTests() - : base(new MssqlDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlExecuteTests.cs deleted file mode 100644 index 6e9705db..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlExecuteTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSSQL -{ - [Collection("Mssql")] - public class MssqlExecuteTests : BaseExecuteTests - { - public MssqlExecuteTests() - : base(new MssqlDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlInsertTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlInsertTests.cs deleted file mode 100644 index e3755a37..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlInsertTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSSQL -{ - [Collection("Mssql")] - public class MssqlInsertTests : BaseInsertTests - { - public MssqlInsertTests() - : base(new MssqlDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlMiscellaneousTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlMiscellaneousTests.cs deleted file mode 100644 index 12d6ddd7..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlMiscellaneousTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSSQL -{ - [Collection("Mssql")] - public class MssqlMiscellaneousTests : BaseMiscellaneousTests - { - public MssqlMiscellaneousTests() - : base(new MssqlDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlStoredProcTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlStoredProcTests.cs deleted file mode 100644 index d1725e13..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlStoredProcTests.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using System.Data.SqlClient; -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSSQL -{ - [Collection("Mssql")] - public class MssqlStoredProcTests : BaseStoredProcTests - { - protected override Type DataParameterType => typeof(SqlParameter); - - public MssqlStoredProcTests() - : base(new MssqlDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlTriageTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlTriageTests.cs deleted file mode 100644 index c8543217..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlTriageTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSSQL -{ - [Collection("Mssql")] - public class MssqlTriageTests : BaseTriageTests - { - public MssqlTriageTests() - : base(new MssqlDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlUpdateTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlUpdateTests.cs deleted file mode 100644 index 99b6fca4..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlUpdateTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSSQL -{ - [Collection("Mssql")] - public class MssqlUpdateTests : BaseUpdateTests - { - public MssqlUpdateTests() - : base(new MssqlDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeDatabaseTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeDatabaseTests.cs deleted file mode 100644 index b85e721d..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeDatabaseTests.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Xunit; - -#if MSSQLCE_TESTS_ENABLED -namespace PetaPoco.Tests.Integration.Databases.MSSQLCe -{ - [Collection("MssqlCe")] - public class MssqlCeDatabaseTests : BaseDatabaseTests - { - public MssqlCeDatabaseTests() - : base(new MssqlCeDBTestProvider()) - { - } - } -} -#endif diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeDeleteTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeDeleteTests.cs deleted file mode 100644 index d18c4029..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeDeleteTests.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Xunit; - -#if MSSQLCE_TESTS_ENABLED -namespace PetaPoco.Tests.Integration.Databases.MSSQLCe -{ - [Collection("MssqlCe")] - public class MssqlCeDeleteTests : BaseDeleteTests - { - public MssqlCeDeleteTests() - : base(new MssqlCeDBTestProvider()) - { - } - } -} -#endif diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeExecuteTests.cs deleted file mode 100644 index efd70473..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeExecuteTests.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Xunit; - -#if MSSQLCE_TESTS_ENABLED -namespace PetaPoco.Tests.Integration.Databases.MSSQLCe -{ - [Collection("MssqlCe")] - public class MssqlCeExecuteTests : BaseExecuteTests - { - public MssqlCeExecuteTests() - : base(new MssqlCeDBTestProvider()) - { - } - } -} -#endif diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeInsertTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeInsertTests.cs deleted file mode 100644 index ae4c2dac..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeInsertTests.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Xunit; - -#if MSSQLCE_TESTS_ENABLED -namespace PetaPoco.Tests.Integration.Databases.MSSQLCe -{ - [Collection("MssqlCe")] - public class MssqlCeInsertTests : BaseInsertTests - { - public MssqlCeInsertTests() - : base(new MssqlCeDBTestProvider()) - { - } - } -} -#endif diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeMiscellaneousTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeMiscellaneousTests.cs deleted file mode 100644 index 03d44936..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeMiscellaneousTests.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Xunit; - -#if MSSQLCE_TESTS_ENABLED -namespace PetaPoco.Tests.Integration.Databases.MSSQLCe -{ - [Collection("MssqlCe")] - public class MssqlCeMiscellaneousTests : BaseMiscellaneousTests - { - public MssqlCeMiscellaneousTests() - : base(new MssqlCeDBTestProvider()) - { - } - } -} -#endif diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeQueryLinqTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeQueryLinqTests.cs deleted file mode 100644 index 0d1f3083..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeQueryLinqTests.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Xunit; - -#if MSSQLCE_TESTS_ENABLED -namespace PetaPoco.Tests.Integration.Databases.MSSQLCe -{ - [Collection("MssqlCe")] - public class MssqlCeQueryLinqTests : BaseQueryLinqTests - { - public MssqlCeQueryLinqTests() - : base(new MssqlCeDBTestProvider()) - { - } - } -} -#endif diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeTriageTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeTriageTests.cs deleted file mode 100644 index 19fde733..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeTriageTests.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Xunit; - -#if MSSQLCE_TESTS_ENABLED -namespace PetaPoco.Tests.Integration.Databases.MSSQLCe -{ - [Collection("MssqlCe")] - public class MssqlCeTriageTests : BaseTriageTests - { - public MssqlCeTriageTests() - : base(new MssqlCeDBTestProvider()) - { - } - } -} -#endif diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeUpdateTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeUpdateTests.cs deleted file mode 100644 index 4f00598d..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeUpdateTests.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Xunit; - -#if MSSQLCE_TESTS_ENABLED -namespace PetaPoco.Tests.Integration.Databases.MSSQLCe -{ - [Collection("MssqlCe")] - public class MssqlCeUpdateTests : BaseUpdateTests - { - public MssqlCeUpdateTests() - : base(new MssqlCeDBTestProvider()) - { - } - } -} -#endif diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataDatabaseTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataDatabaseTests.cs deleted file mode 100644 index 9520e372..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataDatabaseTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSSQLMsData -{ - [Collection("MssqlMsData")] - public class MssqlMsDataDatabaseTests : BaseDatabaseTests - { - public MssqlMsDataDatabaseTests() - : base(new MssqlMsDataDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataDeleteTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataDeleteTests.cs deleted file mode 100644 index edef50b8..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataDeleteTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSSQLMsData -{ - [Collection("MssqlMsData")] - public class MssqlMsDataDeleteTests : BaseDeleteTests - { - public MssqlMsDataDeleteTests() - : base(new MssqlMsDataDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataExecuteTests.cs deleted file mode 100644 index 18bf5328..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataExecuteTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSSQLMsData -{ - [Collection("MssqlMsData")] - public class MssqlMsDataExecuteTests : BaseExecuteTests - { - public MssqlMsDataExecuteTests() - : base(new MssqlMsDataDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataInsertTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataInsertTests.cs deleted file mode 100644 index dbc931e3..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataInsertTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSSQLMsData -{ - [Collection("MssqlMsData")] - public class MssqlMsDataInsertTests : BaseInsertTests - { - public MssqlMsDataInsertTests() - : base(new MssqlMsDataDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataMiscellaneousTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataMiscellaneousTests.cs deleted file mode 100644 index 8f633bc1..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataMiscellaneousTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSSQLMsData -{ - [Collection("MssqlMsData")] - public class MssqlMsDataMiscellaneousTests : BaseMiscellaneousTests - { - public MssqlMsDataMiscellaneousTests() - : base(new MssqlMsDataDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataPreExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataPreExecuteTests.cs deleted file mode 100644 index b0a9b033..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataPreExecuteTests.cs +++ /dev/null @@ -1,198 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Data; -using System.Linq; -using System.Threading.Tasks; -using PetaPoco.Providers; -using Shouldly; -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSSQLMsData -{ - // TODO: Move PreExecute tests to Base class (either BaseExecuteTests or new BasePreExecuteTests) - - [Collection("MssqlMsData")] - public class MssqlMsDataPreExecuteTests : BaseDatabase - { - public MssqlMsDataPreExecuteDatabaseProvider Provider => DB.Provider as MssqlMsDataPreExecuteDatabaseProvider; - - public MssqlMsDataPreExecuteTests() - : base(new MssqlMsDataPreExecuteDBTestProvider()) - { - Provider.ThrowExceptions = true; - } - - [Fact] - public void Query_Calls_PreExecute() - { - var expected = Guid.NewGuid().ToString(); - var sql = Sql.Builder - .Select("*") - .From("sometable") - .Where("foo = @0", expected); - - void act() => DB.Query(sql).First(); - - Should.Throw(act); - Provider.Parameters.Count().ShouldBe(1); - Provider.Parameters.First().Value.ShouldBe(expected); - } - - [Fact] - public void Execute_Calls_PreExecute() - { - var expected = Guid.NewGuid().ToString(); - var sql = Sql.Builder - .Select("*") - .From("sometable") - .Where("foo = @0", expected); - - void act() => DB.Execute(sql); - - Should.Throw(act); - Provider.Parameters.Count().ShouldBe(1); - Provider.Parameters.First().Value.ShouldBe(expected); - } - - [Fact] - public void Insert_Calls_PreExecute() - { - var expected = Guid.NewGuid().ToString(); - - void act() => DB.Insert("sometable", new { Foo = expected }); - - Should.Throw(act); - Provider.Parameters.Count().ShouldBe(1); - Provider.Parameters.First().Value.ShouldBe(expected); - } - - [Fact] - public void Update_Calls_PreExecute() - { - var expected = Guid.NewGuid().ToString(); - - void act() => DB.Update("sometable", "id", new { ID = 3, Foo = expected }); - - Should.Throw(act); - Provider.Parameters.Count().ShouldBe(2); - Provider.Parameters.First().Value.ShouldBe(expected); - } - - [Fact] - public void ExecuteScalar_Calls_PreExecute() - { - var expected = Guid.NewGuid().ToString(); - var sql = Sql.Builder - .Select("count(*)") - .From("sometable") - .Where("foo = @0", expected); - - void act() => DB.ExecuteScalar(sql); - - Should.Throw(act); - Provider.Parameters.Count().ShouldBe(1); - Provider.Parameters.First().Value.ShouldBe(expected); - } - - [Fact] - public async Task QueryAsync_Calls_PreExecute() - { - var expected = Guid.NewGuid().ToString(); - var sql = Sql.Builder - .Select("*") - .From("sometable") - .Where("foo = @0", expected); - - async Task act() => await DB.QueryAsync(sql); - - await Should.ThrowAsync(act); - Provider.Parameters.Count().ShouldBe(1); - Provider.Parameters.First().Value.ShouldBe(expected); - } - - [Fact] - public async Task ExecuteAsync_Calls_PreExecute() - { - var expected = Guid.NewGuid().ToString(); - var sql = Sql.Builder - .Select("*") - .From("sometable") - .Where("foo = @0", expected); - - async Task act() => await DB.ExecuteAsync(sql); - - await Should.ThrowAsync(act); - Provider.Parameters.Count().ShouldBe(1); - Provider.Parameters.First().Value.ShouldBe(expected); - } - - [Fact] - public async Task InsertAsync_Calls_PreExecute() - { - var expected = Guid.NewGuid().ToString(); - - async Task act() => await DB.InsertAsync("sometable", new { Foo = expected }); - - await Should.ThrowAsync(act); - Provider.Parameters.Count().ShouldBe(1); - Provider.Parameters.First().Value.ShouldBe(expected); - } - - [Fact] - public async Task UpdateAsync_Calls_PreExecute() - { - var expected = Guid.NewGuid().ToString(); - - async Task act() => await DB.UpdateAsync("sometable", "id", new { ID = 3, Foo = expected }); - - await Should.ThrowAsync(act); - Provider.Parameters.Count().ShouldBe(2); - Provider.Parameters.First().Value.ShouldBe(expected); - } - - [Fact] - public async Task ExecuteScalarAsync_Calls_PreExecute() - { - var expected = Guid.NewGuid().ToString(); - var sql = Sql.Builder - .Select("count(*)") - .From("sometable") - .Where("foo = @0", expected); - - async Task act() => await DB.ExecuteScalarAsync(sql); - - await Should.ThrowAsync(act); - Provider.Parameters.Count().ShouldBe(1); - Provider.Parameters.First().Value.ShouldBe(expected); - } - - public class MssqlMsDataPreExecuteDBTestProvider : MssqlMsDataDBTestProvider - { - protected override IDatabase LoadFromConnectionName(string name) - { - var config = BuildFromConnectionName(name); - config.UsingProvider(); - return config.Create(); - } - } - - public class MssqlMsDataPreExecuteDatabaseProvider : SqlServerDatabaseProvider - { - public bool ThrowExceptions { get; set; } - public List Parameters { get; set; } = new List(); - - public override void PreExecute(IDbCommand cmd) - { - Parameters.Clear(); - - if (ThrowExceptions) - { - Parameters = cmd.Parameters.Cast().ToList(); - throw new PreExecuteException(); - } - } - } - - public class PreExecuteException : Exception { } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataQueryLinqTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataQueryLinqTests.cs deleted file mode 100644 index e979eead..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataQueryLinqTests.cs +++ /dev/null @@ -1,57 +0,0 @@ -using System; -using PetaPoco.Tests.Integration.Models.MSSQL; -using Shouldly; -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSSQLMsData -{ - [Collection("MssqlMsData")] - public class MssqlMsDataQueryLinqTests : BaseQueryLinqTests - { - #region Test Data - - private readonly StorePerson _storePerson = new StorePerson - { - Id = Guid.NewGuid(), - Age = 18, - Name = "Peta" - }; - - #endregion - - public MssqlMsDataQueryLinqTests() - : base(new MssqlMsDataDBTestProvider()) - { - } - - [Fact] - [Trait("Issue", "#242")] - [Trait("DBFeature", "Schema")] - public void Exists_GivenPrimaryKeyMatchingOneRecordAndPocoWithSchema_ShouldBeTrue() - { - var pk = DB.Insert(_storePerson); - DB.Exists(pk).ShouldBeTrue(); - } - - [Fact] - [Trait("Issue", "#242")] - [Trait("DBFeature", "Schema")] - public void Exists_GivenSqlStringMatchingOneRecordAndPocoWithSchema_ShouldBeTrue() - { - DB.Insert(_storePerson); - DB.Exists($"WHERE {DB.Provider.EscapeSqlIdentifier("Age")} = @0", 18).ShouldBeTrue(); - } - - [Fact(DisplayName = "Exists: Support the older syntax of starting with a WHERE clause.")] - [Trait("Category", "Regression")] - [Trait("Issue", "#237")] - [Trait("Issue", "#238")] - [Trait("Issue", "#242")] - [Trait("DBFeature", "Schema")] - public void Exists_Regression_GivenSqlStringMatchingOneRecordAndPocoWithSchema_ShouldBeTrue() - { - DB.Insert(_storePerson); - DB.Exists($"{DB.Provider.EscapeSqlIdentifier("Age")} = @0", 18).ShouldBeTrue(); - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataQueryTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataQueryTests.cs deleted file mode 100644 index 9c827c05..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataQueryTests.cs +++ /dev/null @@ -1,264 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using PetaPoco.Core; -using PetaPoco.Tests.Integration.Models; -using Shouldly; -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSSQLMsData -{ - [Collection("MssqlMsData")] - public class MssqlMsDataQueryTests : BaseQueryTests - { - public MssqlMsDataQueryTests() - : base(new MssqlMsDataDBTestProvider()) - { - } - - // TODO: Check dbms support and usage for SET/WITH/DECLARE keywords, possibly move to base or other derived classes - [Fact] - [Trait("Issue", "#250")] - [Trait("Issue", "#251")] - public void Query_ForPocoGivenSqlStringStartingWithSet_ShouldReturnValidPocoCollection() - { - AddOrders(12); - var pd = PocoData.ForType(typeof(Order), DB.DefaultMapper); - var sql = "SET CONCAT_NULL_YIELDS_NULL ON;" + - $"SELECT * FROM [{pd.TableInfo.TableName}] WHERE [{pd.Columns.Values.First(c => c.PropertyInfo.Name == "Status").ColumnName}] = @0"; - - var results = DB.Query(sql, OrderStatus.Pending).ToList(); - results.Count.ShouldBe(3); - - results.ForEach(o => - { - o.PoNumber.ShouldStartWith("PO"); - o.Status.ShouldBeOneOf(Enum.GetValues(typeof(OrderStatus)).Cast().ToArray()); - o.PersonId.ShouldNotBe(Guid.Empty); - o.CreatedOn.ShouldBeLessThanOrEqualTo(new DateTime(1990, 1, 1, 0, 0, 0, DateTimeKind.Utc)); - o.CreatedBy.ShouldStartWith("Harry"); - }); - } - - // TODO: Check dbms support and usage for SET/WITH/DECLARE keywords, possibly move to base or other derived classes - [Fact] - [Trait("Issue", "#250")] - [Trait("Issue", "#251")] - public void Query_ForPocoGivenSqlStringStartingWithDeclare_ShouldReturnValidPocoCollection() - { - AddOrders(12); - var pd = PocoData.ForType(typeof(Order), DB.DefaultMapper); - var sql = "DECLARE @@v INT;" + "SET @@v = 1;" + - $"SELECT * FROM [{pd.TableInfo.TableName}] WHERE [{pd.Columns.Values.First(c => c.PropertyInfo.Name == "Status").ColumnName}] = @0"; - - var results = DB.Query(sql, OrderStatus.Pending).ToList(); - results.Count.ShouldBe(3); - - results.ForEach(o => - { - o.PoNumber.ShouldStartWith("PO"); - o.Status.ShouldBeOneOf(Enum.GetValues(typeof(OrderStatus)).Cast().ToArray()); - o.PersonId.ShouldNotBe(Guid.Empty); - o.CreatedOn.ShouldBeLessThanOrEqualTo(new DateTime(1990, 1, 1, 0, 0, 0, DateTimeKind.Utc)); - o.CreatedBy.ShouldStartWith("Harry"); - }); - } - - // TODO: Check dbms support and usage for SET/WITH/DECLARE keywords, possibly move to base or other derived classes - [Fact] - [Trait("Issue", "#250")] - [Trait("Issue", "#251")] - public void Query_ForPocoGivenSqlStringStartingWithWith_ShouldReturnValidPocoCollection() - { - AddOrders(12); - var pd = PocoData.ForType(typeof(Order), DB.DefaultMapper); - var columns = string.Join(", ", pd.Columns.Select(c => DB.Provider.EscapeSqlIdentifier(c.Value.ColumnName))); - var sql = string.Format(@"WITH [{0}_CTE] ({1}) - AS - ( - SELECT {1} FROM {0} - ) - SELECT * - FROM [{0}_CTE] - WHERE [{2}] = @0;", pd.TableInfo.TableName, columns, pd.Columns.Values.First(c => c.PropertyInfo.Name == "Status").ColumnName); - - var results = DB.Query(sql, OrderStatus.Pending).ToList(); - results.Count.ShouldBe(3); - - results.ForEach(o => - { - o.PoNumber.ShouldStartWith("PO"); - o.Status.ShouldBeOneOf(Enum.GetValues(typeof(OrderStatus)).Cast().ToArray()); - o.PersonId.ShouldNotBe(Guid.Empty); - o.CreatedOn.ShouldBeLessThanOrEqualTo(new DateTime(1990, 1, 1, 0, 0, 0, DateTimeKind.Utc)); - o.CreatedBy.ShouldStartWith("Harry"); - }); - } - - [Fact] - public override void QueryMultiple_ForSingleResultsSetWithSinglePoco_ShouldReturnValidPocoCollection() - { - AddPeople(1, 0); - - var pd = PocoData.ForType(typeof(Person), DB.DefaultMapper); - var pdName = pd.Columns.Values.First(c => c.PropertyInfo.Name == "Name").ColumnName; - - var sql = $@"SET CONCAT_NULL_YIELDS_NULL ON; - SELECT * - FROM {DB.Provider.EscapeTableName(pd.TableInfo.TableName)} - WHERE {DB.Provider.EscapeSqlIdentifier(pdName)} LIKE @0 + '%';"; - - List result; - using (var multi = DB.QueryMultiple(sql, "Peta")) - { - result = multi.Read().ToList(); - } - - result.Count.ShouldBe(1); - - var person = result.First(); - person.Id.ShouldNotBe(Guid.Empty); - person.Name.ShouldStartWith("Peta"); - person.Age.ShouldBe(18); - } - - [Fact] - public override void QueryMultiple_ForSingleResultsSetWithMultiPoco_ShouldReturnValidPocoCollection() - { - AddOrders(1); - - var pd = PocoData.ForType(typeof(Person), DB.DefaultMapper); - var od = PocoData.ForType(typeof(Order), DB.DefaultMapper); - var pdId = pd.Columns.Values.First(c => c.PropertyInfo.Name == "Id").ColumnName; - var pdName = pd.Columns.Values.First(c => c.PropertyInfo.Name == "Name").ColumnName; - var odPersonId = od.Columns.Values.First(c => c.PropertyInfo.Name == "PersonId").ColumnName; - - var sql = $@"SET CONCAT_NULL_YIELDS_NULL ON; - SELECT TOP 1 * FROM {DB.Provider.EscapeTableName(od.TableInfo.TableName)} o - INNER JOIN {DB.Provider.EscapeTableName(pd.TableInfo.TableName)} p ON p.{DB.Provider.EscapeSqlIdentifier(pdId)} = o.{DB.Provider.EscapeSqlIdentifier(odPersonId)} - WHERE p.{DB.Provider.EscapeSqlIdentifier(pdName)} = @0 - ORDER BY 1 DESC;"; - - List result; - using (var multi = DB.QueryMultiple(sql, "Peta0")) - { - result = multi.Read((o, p) => - { - o.Person = p; - return o; - }).ToList(); - } - - result.Count.ShouldBe(1); - - var order = result.First(); - - order.PoNumber.ShouldStartWith("PO"); - order.Status.ShouldBeOneOf(Enum.GetValues(typeof(OrderStatus)).Cast().ToArray()); - order.PersonId.ShouldNotBe(Guid.Empty); - order.CreatedOn.ShouldBeLessThanOrEqualTo(new DateTime(1990, 1, 1, 0, 0, 0, DateTimeKind.Utc)); - order.CreatedBy.ShouldStartWith("Harry"); - - order.Person.ShouldNotBeNull(); - order.Person.Id.ShouldNotBe(Guid.Empty); - order.Person.Name.ShouldStartWith("Peta"); - order.Person.Age.ShouldBe(18); - } - - [Fact] - public override void QueryMultiple_ForMultiResultsSetWithSinglePoco_ShouldReturnValidPocoCollection() - { - AddOrders(1); - - var pd = PocoData.ForType(typeof(Person), DB.DefaultMapper); - var od = PocoData.ForType(typeof(Order), DB.DefaultMapper); - var pdName = pd.Columns.Values.First(c => c.PropertyInfo.Name == "Name").ColumnName; - var odId = od.Columns.Values.First(c => c.PropertyInfo.Name == "Id").ColumnName; - - var sql = $@"SET CONCAT_NULL_YIELDS_NULL ON; - SELECT * FROM {DB.Provider.EscapeTableName(od.TableInfo.TableName)} o - WHERE o.{DB.Provider.EscapeSqlIdentifier(odId)} = @0; - SELECT * FROM {DB.Provider.EscapeTableName(pd.TableInfo.TableName)} p - WHERE p.{DB.Provider.EscapeSqlIdentifier(pdName)} = @1;"; - - Order order; - using (var multi = DB.QueryMultiple(sql, "1", "Peta0")) - { - order = multi.Read().First(); - order.Person = multi.Read().First(); - } - - order.PoNumber.ShouldStartWith("PO"); - order.Status.ShouldBeOneOf(Enum.GetValues(typeof(OrderStatus)).Cast().ToArray()); - order.PersonId.ShouldNotBe(Guid.Empty); - order.CreatedOn.ShouldBeLessThanOrEqualTo(new DateTime(1990, 1, 1, 0, 0, 0, DateTimeKind.Utc)); - order.CreatedBy.ShouldStartWith("Harry"); - - order.Person.ShouldNotBeNull(); - order.Person.Id.ShouldNotBe(Guid.Empty); - order.Person.Name.ShouldStartWith("Peta"); - order.Person.Age.ShouldBe(18); - } - - [Fact] - public override void QueryMultiple_ForMultiResultsSetWithMultiPoco_ShouldReturnValidPocoCollection() - { - AddOrders(12); - - var pd = PocoData.ForType(typeof(Person), DB.DefaultMapper); - var od = PocoData.ForType(typeof(Order), DB.DefaultMapper); - var old = PocoData.ForType(typeof(OrderLine), DB.DefaultMapper); - var pdId = pd.Columns.Values.First(c => c.PropertyInfo.Name == "Id").ColumnName; - var odId = od.Columns.Values.First(c => c.PropertyInfo.Name == "Id").ColumnName; - var odPersonId = od.Columns.Values.First(c => c.PropertyInfo.Name == "PersonId").ColumnName; - var oldOrderId = old.Columns.Values.First(c => c.PropertyInfo.Name == "OrderId").ColumnName; - - var sql = $@"SET CONCAT_NULL_YIELDS_NULL ON; - SELECT * FROM {DB.Provider.EscapeTableName(od.TableInfo.TableName)} o - INNER JOIN {DB.Provider.EscapeTableName(pd.TableInfo.TableName)} p ON p.{DB.Provider.EscapeSqlIdentifier(pdId)} = o.{DB.Provider.EscapeSqlIdentifier(odPersonId)} - ORDER BY o.{DB.Provider.EscapeSqlIdentifier(odId)} ASC; - SELECT * FROM {DB.Provider.EscapeTableName(old.TableInfo.TableName)} ol - ORDER BY ol.{DB.Provider.EscapeSqlIdentifier(oldOrderId)} ASC;"; - - List results; - using (var multi = DB.QueryMultiple(sql)) - { - results = multi.Read((o, p) => - { - o.Person = p; - return o; - }).ToList(); - - var orderLines = multi.Read().ToList(); - foreach (var order in results) - order.OrderLines = orderLines.Where(ol => ol.OrderId == order.Id).ToList(); - } - - results.Count.ShouldBe(12); - - results.ForEach(o => - { - o.PoNumber.ShouldStartWith("PO"); - o.Status.ShouldBeOneOf(Enum.GetValues(typeof(OrderStatus)).Cast().ToArray()); - o.PersonId.ShouldNotBe(Guid.Empty); - o.CreatedOn.ShouldBeLessThanOrEqualTo(new DateTime(1990, 1, 1, 0, 0, 0, DateTimeKind.Utc)); - o.CreatedBy.ShouldStartWith("Harry"); - - o.Person.ShouldNotBeNull(); - o.Person.Id.ShouldNotBe(Guid.Empty); - o.Person.Name.ShouldStartWith("Peta"); - o.Person.Age.ShouldBeGreaterThanOrEqualTo(18); - - o.OrderLines.Count.ShouldBe(2); - - var firstOrderLine = o.OrderLines.First(); - firstOrderLine.Quantity.ToString().ShouldBe("1"); - firstOrderLine.SellPrice.ShouldBe(9.99m); - - var secondOrderLine = o.OrderLines.Skip(1).First(); - secondOrderLine.Quantity.ToString().ShouldBe("2"); - secondOrderLine.SellPrice.ShouldBe(19.98m); - }); - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataStoredProcTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataStoredProcTests.cs deleted file mode 100644 index 1578c9a5..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataStoredProcTests.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using Microsoft.Data.SqlClient; -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSSQLMsData -{ - [Collection("MssqlMsData")] - public class MssqlMsDataStoredProcTests : BaseStoredProcTests - { - protected override Type DataParameterType => typeof(SqlParameter); - - public MssqlMsDataStoredProcTests() - : base(new MssqlMsDataDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataTriageTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataTriageTests.cs deleted file mode 100644 index b62a61e8..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataTriageTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSSQLMsData -{ - [Collection("MssqlMsData")] - public class MssqlMsDataTriageTests : BaseTriageTests - { - public MssqlMsDataTriageTests() - : base(new MssqlMsDataDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataUpdateTests.cs b/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataUpdateTests.cs deleted file mode 100644 index 58687fcd..00000000 --- a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataUpdateTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MSSQLMsData -{ - [Collection("MssqlMsData")] - public class MssqlMsDataUpdateTests : BaseUpdateTests - { - public MssqlMsDataUpdateTests() - : base(new MssqlMsDataDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBDatabaseTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBDatabaseTests.cs new file mode 100644 index 00000000..0439d2ce --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBDatabaseTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MariaDB +{ + [Collection("MariaDB")] + public class MariaDBDatabaseTests : DatabaseTests + { + public MariaDBDatabaseTests() + : base(new MariaDBTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBDeleteTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBDeleteTests.cs new file mode 100644 index 00000000..7816a159 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBDeleteTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MariaDB +{ + [Collection("MariaDB")] + public class MariaDBDeleteTests : DeleteTests + { + public MariaDBDeleteTests() + : base(new MariaDBTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBExecuteTests.cs new file mode 100644 index 00000000..2680330e --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBExecuteTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MariaDB +{ + [Collection("MariaDB")] + public class MariaDBExecuteTests : ExecuteTests + { + public MariaDBExecuteTests() + : base(new MariaDBTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBInsertTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBInsertTests.cs new file mode 100644 index 00000000..2a9a731a --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBInsertTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MariaDB +{ + [Collection("MariaDB")] + public class MariaDBInsertTests : InsertTests + { + public MariaDBInsertTests() + : base(new MariaDBTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBMiscellaneousTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBMiscellaneousTests.cs new file mode 100644 index 00000000..c79446db --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBMiscellaneousTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MariaDB +{ + [Collection("MariaDB")] + public class MariaDBMiscellaneousTests : MiscellaneousTests + { + public MariaDBMiscellaneousTests() + : base(new MariaDBTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBPreExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBPreExecuteTests.cs new file mode 100644 index 00000000..616c87b8 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBPreExecuteTests.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using System.Data; +using System.Linq; +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MariaDB +{ + [Collection("MariaDB")] + public class MariaDBPreExecuteTests : PreExecuteTests + { + protected override IPreExecuteDatabaseProvider Provider => DB.Provider as PreExecuteDatabaseProvider; + + public MariaDBPreExecuteTests() + : base(new PreExecuteTestProvider()) + { + Provider.ThrowExceptions = true; + } + + protected class PreExecuteTestProvider : MariaDBTestProvider + { + protected override IDatabase LoadFromConnectionName(string name) + => BuildFromConnectionName(name).UsingProvider().Create(); + } + + protected class PreExecuteDatabaseProvider : PetaPoco.Providers.MariaDbDatabaseProvider, IPreExecuteDatabaseProvider + { + public bool ThrowExceptions { get; set; } + public List Parameters { get; set; } = new List(); + + public override void PreExecute(IDbCommand cmd) + { + Parameters.Clear(); + + if (ThrowExceptions) + { + Parameters = cmd.Parameters.Cast().ToList(); + throw new PreExecuteException(); + } + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBQueryLinqTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBQueryLinqTests.cs new file mode 100644 index 00000000..793fc8b5 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBQueryLinqTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MariaDB +{ + [Collection("MariaDB")] + public class MariaDBQueryLinqTests : QueryLinqTests + { + public MariaDBQueryLinqTests() + : base(new MariaDBTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbQueryTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBQueryTests.cs similarity index 96% rename from PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbQueryTests.cs rename to PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBQueryTests.cs index 1af33f0a..7b7153fb 100644 --- a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbQueryTests.cs +++ b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBQueryTests.cs @@ -3,16 +3,17 @@ using System.Linq; using PetaPoco.Core; using PetaPoco.Tests.Integration.Models; +using PetaPoco.Tests.Integration.Providers; using Shouldly; using Xunit; -namespace PetaPoco.Tests.Integration.Databases.MariaDb +namespace PetaPoco.Tests.Integration.Databases.MariaDB { - [Collection("MariaDb")] - public class MariaDbQueryTests : BaseQueryTests + [Collection("MariaDB")] + public class MariaDBQueryTests : QueryTests { - public MariaDbQueryTests() - : base(new MariaDbDBTestProvider()) + public MariaDBQueryTests() + : base(new MariaDBTestProvider()) { } diff --git a/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBStoredProcTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBStoredProcTests.cs new file mode 100644 index 00000000..4178ff56 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBStoredProcTests.cs @@ -0,0 +1,18 @@ +using System; +using MySql.Data.MySqlClient; +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MariaDB +{ + [Collection("MariaDB")] + public class MariaDBStoredProcTests : StoredProcTests + { + protected override Type DataParameterType => typeof(MySqlParameter); + + public MariaDBStoredProcTests() + : base(new MariaDBTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBTriageTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBTriageTests.cs new file mode 100644 index 00000000..a239a853 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBTriageTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MariaDB +{ + [Collection("MariaDB")] + public class MariaDBTriageTests : TriageTests + { + public MariaDBTriageTests() + : base(new MariaDBTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBUpdateTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBUpdateTests.cs new file mode 100644 index 00000000..bcd88727 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MariaDBTests/MariaDBUpdateTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MariaDB +{ + [Collection("MariaDB")] + public class MariaDBUpdateTests : UpdateTests + { + public MariaDBUpdateTests() + : base(new MariaDBTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbDBTestProvider.cs b/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbDBTestProvider.cs deleted file mode 100644 index 60b0ac8b..00000000 --- a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbDBTestProvider.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace PetaPoco.Tests.Integration.Databases.MariaDb -{ - public class MariaDbDBTestProvider : DBTestProvider - { - protected override string ConnectionName => "MariaDb"; - - protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.MariaDbBuildDatabase.sql"; - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbDatabaseTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbDatabaseTests.cs deleted file mode 100644 index 6e4b4bdc..00000000 --- a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbDatabaseTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MariaDb -{ - [Collection("MariaDb")] - public class MariaDbDatabaseTests : BaseDatabaseTests - { - public MariaDbDatabaseTests() - : base(new MariaDbDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbDeleteTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbDeleteTests.cs deleted file mode 100644 index 9fc557bf..00000000 --- a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbDeleteTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MariaDb -{ - [Collection("MariaDb")] - public class MariaDbDeleteTests : BaseDeleteTests - { - public MariaDbDeleteTests() - : base(new MariaDbDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbExecuteTests.cs deleted file mode 100644 index b10828d9..00000000 --- a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbExecuteTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MariaDb -{ - [Collection("MariaDb")] - public class MariaDbExecuteTests : BaseExecuteTests - { - public MariaDbExecuteTests() - : base(new MariaDbDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbInsertTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbInsertTests.cs deleted file mode 100644 index 1f598e96..00000000 --- a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbInsertTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MariaDb -{ - [Collection("MariaDb")] - public class MariaDbInsertTests : BaseInsertTests - { - public MariaDbInsertTests() - : base(new MariaDbDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbMiscellaneousTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbMiscellaneousTests.cs deleted file mode 100644 index 5c1834b4..00000000 --- a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbMiscellaneousTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MariaDb -{ - [Collection("MariaDb")] - public class MariaDbMiscellaneousTests : BaseMiscellaneousTests - { - public MariaDbMiscellaneousTests() - : base(new MariaDbDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbQueryLinqTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbQueryLinqTests.cs deleted file mode 100644 index d45df6d0..00000000 --- a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbQueryLinqTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MariaDb -{ - [Collection("MariaDb")] - public class MariaDbQueryLinqTests : BaseQueryLinqTests - { - public MariaDbQueryLinqTests() - : base(new MariaDbDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbStoredProcTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbStoredProcTests.cs deleted file mode 100644 index 9f8f9995..00000000 --- a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbStoredProcTests.cs +++ /dev/null @@ -1,17 +0,0 @@ -using System; -using MySql.Data.MySqlClient; -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MariaDb -{ - [Collection("MariaDb")] - public class MariaDbStoredProcTests : BaseStoredProcTests - { - protected override Type DataParameterType => typeof(MySqlParameter); - - public MariaDbStoredProcTests() - : base(new MariaDbDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbTriageTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbTriageTests.cs deleted file mode 100644 index 021ea600..00000000 --- a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbTriageTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MariaDb -{ - [Collection("MariaDb")] - public class MariaDbTriageTests : BaseTriageTests - { - public MariaDbTriageTests() - : base(new MariaDbDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbUpdateTests.cs b/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbUpdateTests.cs deleted file mode 100644 index 3dacc95c..00000000 --- a/PetaPoco.Tests.Integration/Databases/MariaDb/MariaDbUpdateTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MariaDb -{ - [Collection("MariaDb")] - public class MariaDbUpdateTests : BaseUpdateTests - { - public MariaDbUpdateTests() - : base(new MariaDbDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/BaseMiscellaneousTests.cs b/PetaPoco.Tests.Integration/Databases/MiscellaneousTests.cs similarity index 84% rename from PetaPoco.Tests.Integration/Databases/BaseMiscellaneousTests.cs rename to PetaPoco.Tests.Integration/Databases/MiscellaneousTests.cs index dea03e13..4b2345bd 100644 --- a/PetaPoco.Tests.Integration/Databases/BaseMiscellaneousTests.cs +++ b/PetaPoco.Tests.Integration/Databases/MiscellaneousTests.cs @@ -1,11 +1,11 @@ using PetaPoco.Tests.Integration.Models; using Xunit; -namespace PetaPoco.Tests.Integration.Databases +namespace PetaPoco.Tests.Integration { - public abstract class BaseMiscellaneousTests : BaseDatabase + public abstract class MiscellaneousTests : BaseDbContext { - protected BaseMiscellaneousTests(DBTestProvider provider) + protected MiscellaneousTests(TestProvider provider) : base(provider) { } diff --git a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlDBTestProvider.cs b/PetaPoco.Tests.Integration/Databases/MySQL/MySqlDBTestProvider.cs deleted file mode 100644 index 8ada8b1e..00000000 --- a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlDBTestProvider.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace PetaPoco.Tests.Integration.Databases.MySQL -{ - public class MySqlDBTestProvider : DBTestProvider - { - protected override string ConnectionName => "MySQL"; - - protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.MySqlBuildDatabase.sql"; - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlDatabaseTests.cs b/PetaPoco.Tests.Integration/Databases/MySQL/MySqlDatabaseTests.cs deleted file mode 100644 index e59d5f5b..00000000 --- a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlDatabaseTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MySQL -{ - [Collection("MySql")] - public class MySqlDatabaseTests : BaseDatabaseTests - { - public MySqlDatabaseTests() - : base(new MySqlDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlDeleteTests.cs b/PetaPoco.Tests.Integration/Databases/MySQL/MySqlDeleteTests.cs deleted file mode 100644 index 6f931472..00000000 --- a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlDeleteTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MySQL -{ - [Collection("MySql")] - public class MySqlDeleteTests : BaseDeleteTests - { - public MySqlDeleteTests() - : base(new MySqlDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/MySQL/MySqlExecuteTests.cs deleted file mode 100644 index 6b453864..00000000 --- a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlExecuteTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MySQL -{ - [Collection("MySql")] - public class MySqlExecuteTests : BaseExecuteTests - { - public MySqlExecuteTests() - : base(new MySqlDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlInsertTests.cs b/PetaPoco.Tests.Integration/Databases/MySQL/MySqlInsertTests.cs deleted file mode 100644 index 92cd9ffc..00000000 --- a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlInsertTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MySQL -{ - [Collection("MySql")] - public class MySqlInsertTests : BaseInsertTests - { - public MySqlInsertTests() - : base(new MySqlDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlMiscellaneousTests.cs b/PetaPoco.Tests.Integration/Databases/MySQL/MySqlMiscellaneousTests.cs deleted file mode 100644 index ca17c55c..00000000 --- a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlMiscellaneousTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MySQL -{ - [Collection("MySql")] - public class MySqlMiscellaneousTests : BaseDatabase - { - public MySqlMiscellaneousTests() - : base(new MySqlDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlQueryLinqTests.cs b/PetaPoco.Tests.Integration/Databases/MySQL/MySqlQueryLinqTests.cs deleted file mode 100644 index 5c3614d2..00000000 --- a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlQueryLinqTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MySQL -{ - [Collection("MySql")] - public class MySqlQueryLinqTests : BaseQueryLinqTests - { - public MySqlQueryLinqTests() - : base(new MySqlDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlTriageTests.cs b/PetaPoco.Tests.Integration/Databases/MySQL/MySqlTriageTests.cs deleted file mode 100644 index 44c2633a..00000000 --- a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlTriageTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MySQL -{ - [Collection("MySql")] - public class MySqlTriageTests : BaseTriageTests - { - public MySqlTriageTests() - : base(new MySqlDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlUpdateTests.cs b/PetaPoco.Tests.Integration/Databases/MySQL/MySqlUpdateTests.cs deleted file mode 100644 index 7018a645..00000000 --- a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlUpdateTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.MySQL -{ - [Collection("MySql")] - public class MySqlUpdateTests : BaseUpdateTests - { - public MySqlUpdateTests() - : base(new MySqlDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorDBTestProvider.cs b/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorDBTestProvider.cs deleted file mode 100644 index 726e8068..00000000 --- a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorDBTestProvider.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace PetaPoco.Tests.Integration.Databases.MySqlConnector -{ - public class MySqlConnectorDBTestProvider : DBTestProvider - { - protected override string ConnectionName => "mysqlconnector"; - - protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.MySqlBuildDatabase.sql"; - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorDatabaseTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorDatabaseTests.cs similarity index 50% rename from PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorDatabaseTests.cs rename to PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorDatabaseTests.cs index c0357339..39f33c15 100644 --- a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorDatabaseTests.cs +++ b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorDatabaseTests.cs @@ -1,12 +1,13 @@ -using Xunit; +using PetaPoco.Tests.Integration.Providers; +using Xunit; namespace PetaPoco.Tests.Integration.Databases.MySqlConnector { [Collection("MySqlConnector")] - public class MySqlConnectorDatabaseTests : BaseDatabaseTests + public class MySqlConnectorDatabaseTests : DatabaseTests { public MySqlConnectorDatabaseTests() - : base(new MySqlConnectorDBTestProvider()) + : base(new MySqlConnectorTestProvider()) { } } diff --git a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorDeleteTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorDeleteTests.cs similarity index 54% rename from PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorDeleteTests.cs rename to PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorDeleteTests.cs index 47e68b3c..8328f835 100644 --- a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorDeleteTests.cs +++ b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorDeleteTests.cs @@ -1,13 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; using Xunit; namespace PetaPoco.Tests.Integration.Databases.MySqlConnector { [Collection("MySqlConnector")] - public class MySqlConnectorDeleteTests : BaseDeleteTests + public class MySqlConnectorDeleteTests : DeleteTests { public MySqlConnectorDeleteTests() - : base(new MySqlConnectorDBTestProvider()) + : base(new MySqlConnectorTestProvider()) { } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorExecuteTests.cs similarity index 54% rename from PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorExecuteTests.cs rename to PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorExecuteTests.cs index cc9c928b..8800cd6c 100644 --- a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorExecuteTests.cs +++ b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorExecuteTests.cs @@ -1,13 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; using Xunit; namespace PetaPoco.Tests.Integration.Databases.MySqlConnector { [Collection("MySqlConnector")] - public class MySqlConnectorExecuteTests : BaseExecuteTests + public class MySqlConnectorExecuteTests : ExecuteTests { public MySqlConnectorExecuteTests() - : base(new MySqlConnectorDBTestProvider()) + : base(new MySqlConnectorTestProvider()) { } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorInsertTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorInsertTests.cs similarity index 50% rename from PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorInsertTests.cs rename to PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorInsertTests.cs index 0411f6d8..75868673 100644 --- a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorInsertTests.cs +++ b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorInsertTests.cs @@ -1,13 +1,14 @@ -using Xunit; +using PetaPoco.Tests.Integration.Providers; +using Xunit; namespace PetaPoco.Tests.Integration.Databases.MySqlConnector { [Collection("MySqlConnector")] - public class MySqlConnectorInsertTests : BaseInsertTests + public class MySqlConnectorInsertTests : InsertTests { public MySqlConnectorInsertTests() - : base(new MySqlConnectorDBTestProvider()) + : base(new MySqlConnectorTestProvider()) { } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorMiscellaneousTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorMiscellaneousTests.cs similarity index 50% rename from PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorMiscellaneousTests.cs rename to PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorMiscellaneousTests.cs index 0457d9a7..0fce9ada 100644 --- a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorMiscellaneousTests.cs +++ b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorMiscellaneousTests.cs @@ -1,12 +1,13 @@ -using Xunit; +using PetaPoco.Tests.Integration.Providers; +using Xunit; namespace PetaPoco.Tests.Integration.Databases.MySqlConnector { [Collection("MySqlConnector")] - public class MySqlConnectorMiscellaneousTests : BaseDatabase + public class MySqlConnectorMiscellaneousTests : MiscellaneousTests { public MySqlConnectorMiscellaneousTests() - : base(new MySqlConnectorDBTestProvider()) + : base(new MySqlConnectorTestProvider()) { } } diff --git a/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorPreExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorPreExecuteTests.cs new file mode 100644 index 00000000..a4f434f5 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorPreExecuteTests.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using System.Data; +using System.Linq; +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MySqlConnector +{ + [Collection("MySqlConnector")] + public class MySqlConnectorPreExecuteTests : PreExecuteTests + { + protected override IPreExecuteDatabaseProvider Provider => DB.Provider as PreExecuteDatabaseProvider; + + public MySqlConnectorPreExecuteTests() + : base(new PreExecuteTestProvider()) + { + Provider.ThrowExceptions = true; + } + + protected class PreExecuteTestProvider : MySqlConnectorTestProvider + { + protected override IDatabase LoadFromConnectionName(string name) + => BuildFromConnectionName(name).UsingProvider().Create(); + } + + protected class PreExecuteDatabaseProvider : PetaPoco.Providers.MySqlConnectorDatabaseProvider, IPreExecuteDatabaseProvider + { + public bool ThrowExceptions { get; set; } + public List Parameters { get; set; } = new List(); + + public override void PreExecute(IDbCommand cmd) + { + Parameters.Clear(); + + if (ThrowExceptions) + { + Parameters = cmd.Parameters.Cast().ToList(); + throw new PreExecuteException(); + } + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorQueryLinqTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorQueryLinqTests.cs similarity index 50% rename from PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorQueryLinqTests.cs rename to PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorQueryLinqTests.cs index 1894aa68..d293f7a9 100644 --- a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorQueryLinqTests.cs +++ b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorQueryLinqTests.cs @@ -1,13 +1,14 @@ -using Xunit; +using PetaPoco.Tests.Integration.Providers; +using Xunit; namespace PetaPoco.Tests.Integration.Databases.MySqlConnector { [Collection("MySqlConnector")] - public class MySqlConnectorQueryLinqTests : BaseQueryLinqTests + public class MySqlConnectorQueryLinqTests : QueryLinqTests { public MySqlConnectorQueryLinqTests() - : base(new MySqlConnectorDBTestProvider()) + : base(new MySqlConnectorTestProvider()) { } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorQueryTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorQueryTests.cs similarity index 98% rename from PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorQueryTests.cs rename to PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorQueryTests.cs index b2dd0ba1..c19fa4f0 100644 --- a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorQueryTests.cs +++ b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorQueryTests.cs @@ -3,16 +3,17 @@ using System.Linq; using PetaPoco.Core; using PetaPoco.Tests.Integration.Models; +using PetaPoco.Tests.Integration.Providers; using Shouldly; using Xunit; namespace PetaPoco.Tests.Integration.Databases.MySqlConnector { [Collection("MySqlConnector")] - public class MySqlConnectorQueryTests : BaseQueryTests + public class MySqlConnectorQueryTests : QueryTests { public MySqlConnectorQueryTests() - : base(new MySqlConnectorDBTestProvider()) + : base(new MySqlConnectorTestProvider()) { } diff --git a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorStoredProcTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorStoredProcTests.cs similarity index 65% rename from PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorStoredProcTests.cs rename to PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorStoredProcTests.cs index 14fea204..852ef4a9 100644 --- a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorStoredProcTests.cs +++ b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorStoredProcTests.cs @@ -1,17 +1,18 @@ using System; using MySqlConnector; +using PetaPoco.Tests.Integration.Providers; using Xunit; namespace PetaPoco.Tests.Integration.Databases.MySqlConnector { [Collection("MySqlConnector")] - public class MySqlConnectorStoredProcTests : BaseStoredProcTests + public class MySqlConnectorStoredProcTests : StoredProcTests { protected override Type DataParameterType => typeof(MySqlParameter); public MySqlConnectorStoredProcTests() - : base(new MySqlConnectorDBTestProvider()) + : base(new MySqlConnectorTestProvider()) { } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorTriageTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorTriageTests.cs similarity index 51% rename from PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorTriageTests.cs rename to PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorTriageTests.cs index 284ff6a9..4be92be2 100644 --- a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorTriageTests.cs +++ b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorTriageTests.cs @@ -1,12 +1,13 @@ -using Xunit; +using PetaPoco.Tests.Integration.Providers; +using Xunit; namespace PetaPoco.Tests.Integration.Databases.MySqlConnector { [Collection("MySqlConnector")] - public class MySqlConnectorTriageTests : BaseTriageTests + public class MySqlConnectorTriageTests : TriageTests { public MySqlConnectorTriageTests() - : base(new MySqlConnectorDBTestProvider()) + : base(new MySqlConnectorTestProvider()) { } } diff --git a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorUpdateTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorUpdateTests.cs similarity index 54% rename from PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorUpdateTests.cs rename to PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorUpdateTests.cs index 115a9db1..284ca434 100644 --- a/PetaPoco.Tests.Integration/Databases/MySQLConnector/MySqlConnectorUpdateTests.cs +++ b/PetaPoco.Tests.Integration/Databases/MySqlConnectorTests/MySqlConnectorUpdateTests.cs @@ -1,13 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; using Xunit; namespace PetaPoco.Tests.Integration.Databases.MySqlConnector { [Collection("MySqlConnector")] - public class MySqlConnectorUpdateTests : BaseUpdateTests + public class MySqlConnectorUpdateTests : UpdateTests { public MySqlConnectorUpdateTests() - : base(new MySqlConnectorDBTestProvider()) + : base(new MySqlConnectorTestProvider()) { } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlDatabaseTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlDatabaseTests.cs new file mode 100644 index 00000000..928eb3aa --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlDatabaseTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MySql +{ + [Collection("MySql")] + public class MySqlDatabaseTests : DatabaseTests + { + public MySqlDatabaseTests() + : base(new MySqlTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlDeleteTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlDeleteTests.cs new file mode 100644 index 00000000..8edfed4a --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlDeleteTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MySql +{ + [Collection("MySql")] + public class MySqlDeleteTests : DeleteTests + { + public MySqlDeleteTests() + : base(new MySqlTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlExecuteTests.cs new file mode 100644 index 00000000..10644715 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlExecuteTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MySql +{ + [Collection("MySql")] + public class MySqlExecuteTests : ExecuteTests + { + public MySqlExecuteTests() + : base(new MySqlTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlInsertTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlInsertTests.cs new file mode 100644 index 00000000..61c2fac7 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlInsertTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MySql +{ + [Collection("MySql")] + public class MySqlInsertTests : InsertTests + { + public MySqlInsertTests() + : base(new MySqlTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlMiscellaneousTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlMiscellaneousTests.cs new file mode 100644 index 00000000..0d6c2dd8 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlMiscellaneousTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MySql +{ + [Collection("MySql")] + public class MySqlMiscellaneousTests : MiscellaneousTests + { + public MySqlMiscellaneousTests() + : base(new MySqlTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlPreExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlPreExecuteTests.cs new file mode 100644 index 00000000..8420b155 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlPreExecuteTests.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using System.Data; +using System.Linq; +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MySql +{ + [Collection("MySql")] + public class MySqlPreExecuteTests : PreExecuteTests + { + protected override IPreExecuteDatabaseProvider Provider => DB.Provider as PreExecuteDatabaseProvider; + + public MySqlPreExecuteTests() + : base(new PreExecuteTestProvider()) + { + Provider.ThrowExceptions = true; + } + + protected class PreExecuteTestProvider : MySqlTestProvider + { + protected override IDatabase LoadFromConnectionName(string name) + => BuildFromConnectionName(name).UsingProvider().Create(); + } + + protected class PreExecuteDatabaseProvider : PetaPoco.Providers.MySqlDatabaseProvider, IPreExecuteDatabaseProvider + { + public bool ThrowExceptions { get; set; } + public List Parameters { get; set; } = new List(); + + public override void PreExecute(IDbCommand cmd) + { + Parameters.Clear(); + + if (ThrowExceptions) + { + Parameters = cmd.Parameters.Cast().ToList(); + throw new PreExecuteException(); + } + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlQueryLinqTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlQueryLinqTests.cs new file mode 100644 index 00000000..7f34f37b --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlQueryLinqTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MySql +{ + [Collection("MySql")] + public class MySqlQueryLinqTests : QueryLinqTests + { + public MySqlQueryLinqTests() + : base(new MySqlTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlQueryTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlQueryTests.cs similarity index 97% rename from PetaPoco.Tests.Integration/Databases/MySQL/MySqlQueryTests.cs rename to PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlQueryTests.cs index dac956e2..f56cad8d 100644 --- a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlQueryTests.cs +++ b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlQueryTests.cs @@ -3,16 +3,17 @@ using System.Linq; using PetaPoco.Core; using PetaPoco.Tests.Integration.Models; +using PetaPoco.Tests.Integration.Providers; using Shouldly; using Xunit; -namespace PetaPoco.Tests.Integration.Databases.MySQL +namespace PetaPoco.Tests.Integration.Databases.MySql { [Collection("MySql")] - public class MySqlQueryTests : BaseQueryTests + public class MySqlQueryTests : QueryTests { public MySqlQueryTests() - : base(new MySqlDBTestProvider()) + : base(new MySqlTestProvider()) { } diff --git a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlStoredProcTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlStoredProcTests.cs similarity index 54% rename from PetaPoco.Tests.Integration/Databases/MySQL/MySqlStoredProcTests.cs rename to PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlStoredProcTests.cs index 77ce8172..e8368a64 100644 --- a/PetaPoco.Tests.Integration/Databases/MySQL/MySqlStoredProcTests.cs +++ b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlStoredProcTests.cs @@ -1,17 +1,18 @@ using System; using MySql.Data.MySqlClient; +using PetaPoco.Tests.Integration.Providers; using Xunit; -namespace PetaPoco.Tests.Integration.Databases.MySQL +namespace PetaPoco.Tests.Integration.Databases.MySql { [Collection("MySql")] - public class MySqlStoredProcTests : BaseStoredProcTests + public class MySqlStoredProcTests : StoredProcTests { protected override Type DataParameterType => typeof(MySqlParameter); public MySqlStoredProcTests() - : base(new MySqlDBTestProvider()) + : base(new MySqlTestProvider()) { } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlTriageTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlTriageTests.cs new file mode 100644 index 00000000..24269d22 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlTriageTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MySql +{ + [Collection("MySql")] + public class MySqlTriageTests : TriageTests + { + public MySqlTriageTests() + : base(new MySqlTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlUpdateTests.cs b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlUpdateTests.cs new file mode 100644 index 00000000..7766cd41 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/MySqlTests/MySqlUpdateTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.MySql +{ + [Collection("MySql")] + public class MySqlUpdateTests : UpdateTests + { + public MySqlUpdateTests() + : base(new MySqlTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresDatabaseTests.cs b/PetaPoco.Tests.Integration/Databases/Postgres/PostgresDatabaseTests.cs deleted file mode 100644 index 46cd2d5e..00000000 --- a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresDatabaseTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.Postgres -{ - [Collection("Postgres")] - public class PostgresDatabaseTests : BaseDatabaseTests - { - public PostgresDatabaseTests() - : base(new PostgresDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/Postgres/PostgresExecuteTests.cs deleted file mode 100644 index 791948ab..00000000 --- a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresExecuteTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.Postgres -{ - [Collection("Postgres")] - public class PostgresExecuteTests : BaseExecuteTests - { - public PostgresExecuteTests() - : base(new PostgresDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresMiscellaneousTests.cs b/PetaPoco.Tests.Integration/Databases/Postgres/PostgresMiscellaneousTests.cs deleted file mode 100644 index a7aaaa69..00000000 --- a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresMiscellaneousTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.Postgres -{ - [Collection("Postgres")] - public class PostgresMiscellaneousTests : BaseMiscellaneousTests - { - public PostgresMiscellaneousTests() - : base(new PostgresDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresQueryLinqTests.cs b/PetaPoco.Tests.Integration/Databases/Postgres/PostgresQueryLinqTests.cs deleted file mode 100644 index bf7f5389..00000000 --- a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresQueryLinqTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.Postgres -{ - [Collection("Postgres")] - public class PostgresQueryLinqTests : BaseQueryLinqTests - { - public PostgresQueryLinqTests() - : base(new PostgresDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresDatabaseTests.cs b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresDatabaseTests.cs new file mode 100644 index 00000000..a6c73e3b --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresDatabaseTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.Postgres +{ + [Collection("Postgres")] + public class PostgresDatabaseTests : DatabaseTests + { + public PostgresDatabaseTests() + : base(new PostgresTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresDeleteTests.cs b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresDeleteTests.cs similarity index 54% rename from PetaPoco.Tests.Integration/Databases/Postgres/PostgresDeleteTests.cs rename to PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresDeleteTests.cs index 34769226..79ef610e 100644 --- a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresDeleteTests.cs +++ b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresDeleteTests.cs @@ -1,13 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; using Xunit; namespace PetaPoco.Tests.Integration.Databases.Postgres { [Collection("Postgres")] - public class PostgresDeleteTests : BaseDeleteTests + public class PostgresDeleteTests : DeleteTests { public PostgresDeleteTests() - : base(new PostgresDBTestProvider()) + : base(new PostgresTestProvider()) { } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresExecuteTests.cs new file mode 100644 index 00000000..06893e7f --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresExecuteTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.Postgres +{ + [Collection("Postgres")] + public class PostgresExecuteTests : ExecuteTests + { + public PostgresExecuteTests() + : base(new PostgresTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresInsertTests.cs b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresInsertTests.cs similarity index 83% rename from PetaPoco.Tests.Integration/Databases/Postgres/PostgresInsertTests.cs rename to PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresInsertTests.cs index 9409791a..618b125c 100644 --- a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresInsertTests.cs +++ b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresInsertTests.cs @@ -1,14 +1,15 @@ using PetaPoco.Tests.Integration.Models.Postgres; +using PetaPoco.Tests.Integration.Providers; using Shouldly; using Xunit; namespace PetaPoco.Tests.Integration.Databases.Postgres { [Collection("Postgres")] - public class PostgresInsertTests : BaseInsertTests + public class PostgresInsertTests : InsertTests { public PostgresInsertTests() - : base(new PostgresDBTestProvider()) + : base(new PostgresTestProvider()) { } diff --git a/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresMiscellaneousTests.cs b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresMiscellaneousTests.cs new file mode 100644 index 00000000..af801a3d --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresMiscellaneousTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.Postgres +{ + [Collection("Postgres")] + public class PostgresMiscellaneousTests : MiscellaneousTests + { + public PostgresMiscellaneousTests() + : base(new PostgresTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresPreExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresPreExecuteTests.cs new file mode 100644 index 00000000..17c5c065 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresPreExecuteTests.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using System.Data; +using System.Linq; +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.Postgres +{ + [Collection("Postgres")] + public class PostgresPreExecuteTests : PreExecuteTests + { + protected override IPreExecuteDatabaseProvider Provider => DB.Provider as PreExecuteDatabaseProvider; + + public PostgresPreExecuteTests() + : base(new PreExecuteTestProvider()) + { + Provider.ThrowExceptions = true; + } + + protected class PreExecuteTestProvider : PostgresTestProvider + { + protected override IDatabase LoadFromConnectionName(string name) + => BuildFromConnectionName(name).UsingProvider().Create(); + } + + protected class PreExecuteDatabaseProvider : PetaPoco.Providers.PostgreSQLDatabaseProvider, IPreExecuteDatabaseProvider + { + public bool ThrowExceptions { get; set; } + public List Parameters { get; set; } = new List(); + + public override void PreExecute(IDbCommand cmd) + { + Parameters.Clear(); + + if (ThrowExceptions) + { + Parameters = cmd.Parameters.Cast().ToList(); + throw new PreExecuteException(); + } + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresQueryLinqTests.cs b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresQueryLinqTests.cs new file mode 100644 index 00000000..f214cb65 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresQueryLinqTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.Postgres +{ + [Collection("Postgres")] + public class PostgresQueryLinqTests : QueryLinqTests + { + public PostgresQueryLinqTests() + : base(new PostgresTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresQueryTests.cs b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresQueryTests.cs similarity index 98% rename from PetaPoco.Tests.Integration/Databases/Postgres/PostgresQueryTests.cs rename to PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresQueryTests.cs index d46e261f..b962610d 100644 --- a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresQueryTests.cs +++ b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresQueryTests.cs @@ -3,16 +3,17 @@ using System.Linq; using PetaPoco.Core; using PetaPoco.Tests.Integration.Models; +using PetaPoco.Tests.Integration.Providers; using Shouldly; using Xunit; namespace PetaPoco.Tests.Integration.Databases.Postgres { [Collection("Postgres")] - public class PostgresQueryTests : BaseQueryTests + public class PostgresQueryTests : QueryTests { public PostgresQueryTests() - : base(new PostgresDBTestProvider()) + : base(new PostgresTestProvider()) { } diff --git a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresStoredProcTests.cs b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresStoredProcTests.cs similarity index 65% rename from PetaPoco.Tests.Integration/Databases/Postgres/PostgresStoredProcTests.cs rename to PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresStoredProcTests.cs index c2a3b93d..f38dfc4f 100644 --- a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresStoredProcTests.cs +++ b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresStoredProcTests.cs @@ -1,17 +1,18 @@ using System; using Npgsql; +using PetaPoco.Tests.Integration.Providers; using Xunit; namespace PetaPoco.Tests.Integration.Databases.Postgres { [Collection("Postgres")] - public class PostgresStoredProcTests : BaseStoredProcTests + public class PostgresStoredProcTests : StoredProcTests { protected override Type DataParameterType => typeof(NpgsqlParameter); public PostgresStoredProcTests() - : base(new PostgresDBTestProvider()) + : base(new PostgresTestProvider()) { } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresTriageTests.cs b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresTriageTests.cs similarity index 50% rename from PetaPoco.Tests.Integration/Databases/Postgres/PostgresTriageTests.cs rename to PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresTriageTests.cs index 7d55ef0f..eab6e708 100644 --- a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresTriageTests.cs +++ b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresTriageTests.cs @@ -1,12 +1,13 @@ -using Xunit; +using PetaPoco.Tests.Integration.Providers; +using Xunit; namespace PetaPoco.Tests.Integration.Databases.Postgres { [Collection("Postgres")] - public class PostgresTriageTests : BaseTriageTests + public class PostgresTriageTests : TriageTests { public PostgresTriageTests() - : base(new PostgresDBTestProvider()) + : base(new PostgresTestProvider()) { } } diff --git a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresUpdateTests.cs b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresUpdateTests.cs similarity index 86% rename from PetaPoco.Tests.Integration/Databases/Postgres/PostgresUpdateTests.cs rename to PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresUpdateTests.cs index aef7b667..227f995c 100644 --- a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresUpdateTests.cs +++ b/PetaPoco.Tests.Integration/Databases/PostgresTests/PostgresUpdateTests.cs @@ -1,14 +1,15 @@ using PetaPoco.Tests.Integration.Models.Postgres; +using PetaPoco.Tests.Integration.Providers; using Shouldly; using Xunit; namespace PetaPoco.Tests.Integration.Databases.Postgres { [Collection("Postgres")] - public class PostgresUpdateTests : BaseUpdateTests + public class PostgresUpdateTests : UpdateTests { public PostgresUpdateTests() - : base(new PostgresDBTestProvider()) + : base(new PostgresTestProvider()) { } diff --git a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlPreExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/PreExecuteTests.cs similarity index 69% rename from PetaPoco.Tests.Integration/Databases/MSSQL/MssqlPreExecuteTests.cs rename to PetaPoco.Tests.Integration/Databases/PreExecuteTests.cs index e13753ef..bad305f5 100644 --- a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlPreExecuteTests.cs +++ b/PetaPoco.Tests.Integration/Databases/PreExecuteTests.cs @@ -3,27 +3,22 @@ using System.Data; using System.Linq; using System.Threading.Tasks; -using PetaPoco.Providers; using Shouldly; using Xunit; -namespace PetaPoco.Tests.Integration.Databases.MSSQL +namespace PetaPoco.Tests.Integration { - // TODO: Move PreExecute tests to Base class (either BaseExecuteTests or new BasePreExecuteTests) - - [Collection("Mssql")] - public class MssqlPreExecuteTests : BaseDatabase + public abstract class PreExecuteTests : BaseDbContext { - public MsssqlPreExecuteDatabaseProvider Provider => DB.Provider as MsssqlPreExecuteDatabaseProvider; + protected abstract IPreExecuteDatabaseProvider Provider { get; } - public MssqlPreExecuteTests() - : base(new MssqlPreExecuteDBTestProvider()) + protected PreExecuteTests(TestProvider provider) + : base(provider) { - Provider.ThrowExceptions = true; } [Fact] - public void Query_Calls_PreExecute() + public virtual void Execute_Calls_PreExecute() { var expected = Guid.NewGuid().ToString(); var sql = Sql.Builder @@ -31,7 +26,7 @@ public void Query_Calls_PreExecute() .From("sometable") .Where("foo = @0", expected); - void act() => DB.Query(sql).First(); + void act() => DB.Execute(sql); Should.Throw(act); Provider.Parameters.Count().ShouldBe(1); @@ -39,7 +34,7 @@ public void Query_Calls_PreExecute() } [Fact] - public void Execute_Calls_PreExecute() + public virtual async Task ExecuteAsync_Calls_PreExecute() { var expected = Guid.NewGuid().ToString(); var sql = Sql.Builder @@ -47,19 +42,23 @@ public void Execute_Calls_PreExecute() .From("sometable") .Where("foo = @0", expected); - void act() => DB.Execute(sql); + async Task act() => await DB.ExecuteAsync(sql); - Should.Throw(act); + await Should.ThrowAsync(act); Provider.Parameters.Count().ShouldBe(1); Provider.Parameters.First().Value.ShouldBe(expected); } [Fact] - public void Insert_Calls_PreExecute() + public virtual void ExecuteScalar_Calls_PreExecute() { var expected = Guid.NewGuid().ToString(); + var sql = Sql.Builder + .Select("count(*)") + .From("sometable") + .Where("foo = @0", expected); - void act() => DB.Insert("sometable", new { Foo = expected }); + void act() => DB.ExecuteScalar(sql); Should.Throw(act); Provider.Parameters.Count().ShouldBe(1); @@ -67,27 +66,27 @@ public void Insert_Calls_PreExecute() } [Fact] - public void Update_Calls_PreExecute() + public virtual async Task ExecuteScalarAsync_Calls_PreExecute() { var expected = Guid.NewGuid().ToString(); + var sql = Sql.Builder + .Select("count(*)") + .From("sometable") + .Where("foo = @0", expected); - void act() => DB.Update("sometable", "id", new { ID = 3, Foo = expected }); + async Task act() => await DB.ExecuteScalarAsync(sql); - Should.Throw(act); - Provider.Parameters.Count().ShouldBe(2); + await Should.ThrowAsync(act); + Provider.Parameters.Count().ShouldBe(1); Provider.Parameters.First().Value.ShouldBe(expected); } [Fact] - public void ExecuteScalar_Calls_PreExecute() + public virtual void Insert_Calls_PreExecute() { var expected = Guid.NewGuid().ToString(); - var sql = Sql.Builder - .Select("count(*)") - .From("sometable") - .Where("foo = @0", expected); - void act() => DB.ExecuteScalar(sql); + void act() => DB.Insert("sometable", new { Foo = expected }); Should.Throw(act); Provider.Parameters.Count().ShouldBe(1); @@ -95,15 +94,11 @@ public void ExecuteScalar_Calls_PreExecute() } [Fact] - public async Task QueryAsync_Calls_PreExecute() + public virtual async Task InsertAsync_Calls_PreExecute() { var expected = Guid.NewGuid().ToString(); - var sql = Sql.Builder - .Select("*") - .From("sometable") - .Where("foo = @0", expected); - async Task act() => await DB.QueryAsync(sql); + async Task act() => await DB.InsertAsync("sometable", new { Foo = expected }); await Should.ThrowAsync(act); Provider.Parameters.Count().ShouldBe(1); @@ -111,7 +106,7 @@ public async Task QueryAsync_Calls_PreExecute() } [Fact] - public async Task ExecuteAsync_Calls_PreExecute() + public virtual void Query_Calls_PreExecute() { var expected = Guid.NewGuid().ToString(); var sql = Sql.Builder @@ -119,19 +114,23 @@ public async Task ExecuteAsync_Calls_PreExecute() .From("sometable") .Where("foo = @0", expected); - async Task act() => await DB.ExecuteAsync(sql); + void act() => DB.Query(sql).First(); - await Should.ThrowAsync(act); + Should.Throw(act); Provider.Parameters.Count().ShouldBe(1); Provider.Parameters.First().Value.ShouldBe(expected); } [Fact] - public async Task InsertAsync_Calls_PreExecute() + public virtual async Task QueryAsync_Calls_PreExecute() { var expected = Guid.NewGuid().ToString(); + var sql = Sql.Builder + .Select("*") + .From("sometable") + .Where("foo = @0", expected); - async Task act() => await DB.InsertAsync("sometable", new { Foo = expected }); + async Task act() => await DB.QueryAsync(sql); await Should.ThrowAsync(act); Provider.Parameters.Count().ShouldBe(1); @@ -139,59 +138,35 @@ public async Task InsertAsync_Calls_PreExecute() } [Fact] - public async Task UpdateAsync_Calls_PreExecute() + public virtual void Update_Calls_PreExecute() { var expected = Guid.NewGuid().ToString(); - async Task act() => await DB.UpdateAsync("sometable", "id", new { ID = 3, Foo = expected }); + void act() => DB.Update("sometable", "id", new { ID = 3, Foo = expected }); - await Should.ThrowAsync(act); + Should.Throw(act); Provider.Parameters.Count().ShouldBe(2); Provider.Parameters.First().Value.ShouldBe(expected); } [Fact] - public async Task ExecuteScalarAsync_Calls_PreExecute() + public virtual async Task UpdateAsync_Calls_PreExecute() { var expected = Guid.NewGuid().ToString(); - var sql = Sql.Builder - .Select("count(*)") - .From("sometable") - .Where("foo = @0", expected); - async Task act() => await DB.ExecuteScalarAsync(sql); + async Task act() => await DB.UpdateAsync("sometable", "id", new { ID = 3, Foo = expected }); await Should.ThrowAsync(act); - Provider.Parameters.Count().ShouldBe(1); + Provider.Parameters.Count().ShouldBe(2); Provider.Parameters.First().Value.ShouldBe(expected); } - - public class MssqlPreExecuteDBTestProvider : MssqlDBTestProvider + public interface IPreExecuteDatabaseProvider { - protected override IDatabase LoadFromConnectionName(string name) - { - var config = BuildFromConnectionName(name); - config.UsingProvider(); - return config.Create(); - } - } + bool ThrowExceptions { get; set; } + List Parameters { get; set; } - public class MsssqlPreExecuteDatabaseProvider : SqlServerDatabaseProvider - { - public bool ThrowExceptions { get; set; } - public List Parameters { get; set; } = new List(); - - public override void PreExecute(IDbCommand cmd) - { - Parameters.Clear(); - - if (ThrowExceptions) - { - Parameters = cmd.Parameters.Cast().ToList(); - throw new PreExecuteException(); - } - } + void PreExecute(IDbCommand cmd); } public class PreExecuteException : Exception { } diff --git a/PetaPoco.Tests.Integration/Databases/BaseQueryLinqTests.cs b/PetaPoco.Tests.Integration/Databases/QueryLinqTests.cs similarity index 98% rename from PetaPoco.Tests.Integration/Databases/BaseQueryLinqTests.cs rename to PetaPoco.Tests.Integration/Databases/QueryLinqTests.cs index e724ea43..3e9a96ea 100644 --- a/PetaPoco.Tests.Integration/Databases/BaseQueryLinqTests.cs +++ b/PetaPoco.Tests.Integration/Databases/QueryLinqTests.cs @@ -6,9 +6,9 @@ // TODO: Use specific exception types when asserting thrown exceptions -namespace PetaPoco.Tests.Integration.Databases +namespace PetaPoco.Tests.Integration { - public abstract class BaseQueryLinqTests : BaseDatabase + public abstract class QueryLinqTests : BaseDbContext { // TODO: Move to base class, combine with other test data #region Test Data @@ -39,7 +39,7 @@ public abstract class BaseQueryLinqTests : BaseDatabase #endregion - protected BaseQueryLinqTests(DBTestProvider provider) + protected QueryLinqTests(TestProvider provider) : base(provider) { } @@ -316,7 +316,7 @@ public virtual async Task ExistsAsync_GivenPrimaryKeyMatchingNoRecord_ShouldBeFa (await DB.ExistsAsync(Guid.NewGuid())).ShouldBeFalse(); } - [Fact(DisplayName = "Exists: Support the older syntax of starting with a WHERE clause.")] + [Fact(DisplayName = "ExistsAsync: Support the older syntax of starting with a WHERE clause.")] [Trait("Category", "Regression")] [Trait("Issue", "#237")] [Trait("Issue", "#238")] diff --git a/PetaPoco.Tests.Integration/Databases/BaseQueryTests.cs b/PetaPoco.Tests.Integration/Databases/QueryTests.cs similarity index 99% rename from PetaPoco.Tests.Integration/Databases/BaseQueryTests.cs rename to PetaPoco.Tests.Integration/Databases/QueryTests.cs index db986e85..203a51ec 100644 --- a/PetaPoco.Tests.Integration/Databases/BaseQueryTests.cs +++ b/PetaPoco.Tests.Integration/Databases/QueryTests.cs @@ -9,11 +9,11 @@ using Shouldly; using Xunit; -namespace PetaPoco.Tests.Integration.Databases +namespace PetaPoco.Tests.Integration { - public abstract class BaseQueryTests : BaseDatabase + public abstract class QueryTests : BaseDbContext { - protected BaseQueryTests(DBTestProvider provider) + protected QueryTests(TestProvider provider) : base(provider) { } diff --git a/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteDatabaseTests.cs b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteDatabaseTests.cs new file mode 100644 index 00000000..5307fbf3 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteDatabaseTests.cs @@ -0,0 +1,47 @@ +using System.Reflection; +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SQLite +{ + public abstract partial class SQLiteDatabaseTests : DatabaseTests + { + private readonly SQLiteTestProvider _provider; + + protected SQLiteDatabaseTests(SQLiteTestProvider provider) + : base(provider) + { + _provider = provider; + } + + /// + /// This is required because we can't use the Mapper.* methods, as we're testing many different databases and it would apply Sqlite + /// logic incorrectly. + /// + protected override void AfterDbCreate(Database db) + { + base.AfterDbCreate(db); + + // ReSharper disable once PossibleNullReferenceException + db.GetType().GetField("_defaultMapper", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(db, _provider.GetDatabase().DefaultMapper); + } + + [Collection("SQLite.SystemData")] + public class SystemData : SQLiteDatabaseTests + { + public SystemData() + : base(new SQLiteSystemDataTestProvider()) + { + } + } + + [Collection("SQLite.MicrosoftData")] + public class MicrosoftData : SQLiteDatabaseTests + { + public MicrosoftData() + : base(new SQLiteMSDataTestProvider()) + { + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteDeleteTests.cs b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteDeleteTests.cs new file mode 100644 index 00000000..5bbe2cfe --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteDeleteTests.cs @@ -0,0 +1,31 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SQLite +{ + public abstract partial class SQLiteDeleteTests : DeleteTests + { + protected SQLiteDeleteTests(TestProvider provider) + : base(provider) + { + } + + [Collection("SQLite.SystemData")] + public class SystemData : SQLiteDeleteTests + { + public SystemData() + : base(new SQLiteSystemDataTestProvider()) + { + } + } + + [Collection("SQLite.MicrosoftData")] + public class MicrosoftData : SQLiteDeleteTests + { + public MicrosoftData() + : base(new SQLiteMSDataTestProvider()) + { + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteExecuteTests.cs new file mode 100644 index 00000000..d1492385 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteExecuteTests.cs @@ -0,0 +1,31 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SQLite +{ + public abstract partial class SQLiteExecuteTests : ExecuteTests + { + protected SQLiteExecuteTests(TestProvider provider) + : base(provider) + { + } + + [Collection("SQLite.SystemData")] + public class SystemData : SQLiteExecuteTests + { + public SystemData() + : base(new SQLiteSystemDataTestProvider()) + { + } + } + + [Collection("SQLite.MicrosoftData")] + public class MicrosoftData : SQLiteExecuteTests + { + public MicrosoftData() + : base(new SQLiteMSDataTestProvider()) + { + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteInsertTests.cs b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteInsertTests.cs new file mode 100644 index 00000000..174c821b --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteInsertTests.cs @@ -0,0 +1,31 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SQLite +{ + public abstract partial class SQLiteInsertTests : InsertTests + { + protected SQLiteInsertTests(TestProvider provider) + : base(provider) + { + } + + [Collection("SQLite.SystemData")] + public class SystemData : SQLiteInsertTests + { + public SystemData() + : base(new SQLiteSystemDataTestProvider()) + { + } + } + + [Collection("SQLite.MicrosoftData")] + public class MicrosoftData : SQLiteInsertTests + { + public MicrosoftData() + : base(new SQLiteMSDataTestProvider()) + { + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteMiscellaneousTests.cs b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteMiscellaneousTests.cs new file mode 100644 index 00000000..b305effd --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteMiscellaneousTests.cs @@ -0,0 +1,31 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SQLite +{ + public abstract partial class SQLiteMiscellaneousTests : MiscellaneousTests + { + protected SQLiteMiscellaneousTests(TestProvider provider) + : base(provider) + { + } + + [Collection("SQLite.SystemData")] + public class SystemData : SQLiteMiscellaneousTests + { + public SystemData() + : base(new SQLiteSystemDataTestProvider()) + { + } + } + + [Collection("SQLite.MicrosoftData")] + public class MicrosoftData : SQLiteMiscellaneousTests + { + public MicrosoftData() + : base(new SQLiteMSDataTestProvider()) + { + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLitePreExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLitePreExecuteTests.cs new file mode 100644 index 00000000..61ede4d3 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLitePreExecuteTests.cs @@ -0,0 +1,87 @@ +using System.Collections.Generic; +using System.Data; +using System.Linq; +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SQLite +{ + [Collection("SQLite")] + public abstract partial class SQLitePreExecuteTests : PreExecuteTests + { + protected SQLitePreExecuteTests(TestProvider provider) + : base(provider) + { + } + + [Collection("SQLite.SystemData")] + public class SystemData : SQLitePreExecuteTests + { + protected override IPreExecuteDatabaseProvider Provider => DB.Provider as PreExecuteDatabaseProvider; + + public SystemData() + : base(new PreExecuteTestProvider()) + { + Provider.ThrowExceptions = true; + } + + protected class PreExecuteTestProvider : SQLiteSystemDataTestProvider + { + protected override IDatabase LoadFromConnectionName(string name) + => BuildFromConnectionName(name).UsingProvider().Create(); + } + + protected class PreExecuteDatabaseProvider : PetaPoco.Providers.SQLiteDatabaseProvider, IPreExecuteDatabaseProvider + { + public bool ThrowExceptions { get; set; } + public List Parameters { get; set; } = new List(); + + public override void PreExecute(IDbCommand cmd) + { + Parameters.Clear(); + + if (ThrowExceptions) + { + Parameters = cmd.Parameters.Cast().ToList(); + throw new PreExecuteException(); + } + } + } + } + + [Collection("SQLite.MicrosoftData")] + public class MicrosoftData : SQLitePreExecuteTests + { + protected override IPreExecuteDatabaseProvider Provider => DB.Provider as PreExecuteDatabaseProvider; + + public MicrosoftData() + : base(new PreExecuteTestProvider()) + { + Provider.ThrowExceptions = true; + } + + protected class PreExecuteTestProvider : SQLiteMSDataTestProvider + { + protected override IDatabase LoadFromConnectionName(string name) + => BuildFromConnectionName(name).UsingProvider().Create(); + } + + protected class PreExecuteDatabaseProvider : PetaPoco.Providers.SQLiteDatabaseProvider, IPreExecuteDatabaseProvider + { + public bool ThrowExceptions { get; set; } + public List Parameters { get; set; } = new List(); + + public override void PreExecute(IDbCommand cmd) + { + Parameters.Clear(); + + if (ThrowExceptions) + { + Parameters = cmd.Parameters.Cast().ToList(); + throw new PreExecuteException(); + } + } + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteQueryLinqTests.cs b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteQueryLinqTests.cs new file mode 100644 index 00000000..5b5a5448 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteQueryLinqTests.cs @@ -0,0 +1,31 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SQLite +{ + public abstract partial class SQLiteQueryLinqTests : QueryLinqTests + { + protected SQLiteQueryLinqTests(TestProvider provider) + : base(provider) + { + } + + [Collection("SQLite.SystemData")] + public class SystemData : SQLiteQueryLinqTests + { + public SystemData() + : base(new SQLiteSystemDataTestProvider()) + { + } + } + + [Collection("SQLite.MicrosoftData")] + public class MicrosoftData : SQLiteQueryLinqTests + { + public MicrosoftData() + : base(new SQLiteMSDataTestProvider()) + { + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteQueryTests.cs b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteQueryTests.cs similarity index 91% rename from PetaPoco.Tests.Integration/Databases/Sqlite/SqliteQueryTests.cs rename to PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteQueryTests.cs index 0b81abe7..663ea2d6 100644 --- a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteQueryTests.cs +++ b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteQueryTests.cs @@ -3,16 +3,16 @@ using System.Linq; using PetaPoco.Core; using PetaPoco.Tests.Integration.Models; +using PetaPoco.Tests.Integration.Providers; using Shouldly; using Xunit; -namespace PetaPoco.Tests.Integration.Databases.Sqlite +namespace PetaPoco.Tests.Integration.Databases.SQLite { - [Collection("Sqlite")] - public class SqliteQueryTests : BaseQueryTests + public abstract partial class SQLiteQueryTests : QueryTests { - public SqliteQueryTests() - : base(new SqliteDBTestProvider()) + protected SQLiteQueryTests(TestProvider provider) + : base(provider) { } @@ -178,5 +178,23 @@ public override void QueryMultiple_ForMultiResultsSetWithMultiPoco_ShouldReturnV secondOrderLine.SellPrice.ShouldBe(19.98m); }); } + + [Collection("SQLite.SystemData")] + public class SystemData : SQLiteQueryTests + { + public SystemData() + : base(new SQLiteSystemDataTestProvider()) + { + } + } + + [Collection("SQLite.MicrosoftData")] + public class MicrosoftData : SQLiteQueryTests + { + public MicrosoftData() + : base(new SQLiteMSDataTestProvider()) + { + } + } } } diff --git a/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteTriageTests.cs b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteTriageTests.cs new file mode 100644 index 00000000..5fe0aa65 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteTriageTests.cs @@ -0,0 +1,31 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SQLite +{ + public abstract partial class SQLiteTriageTests : TriageTests + { + protected SQLiteTriageTests(TestProvider provider) + : base(provider) + { + } + + [Collection("SQLite.SystemData")] + public class SystemData : SQLiteTriageTests + { + public SystemData() + : base(new SQLiteSystemDataTestProvider()) + { + } + } + + [Collection("SQLite.MicrosoftData")] + public class MicrosoftData : SQLiteTriageTests + { + public MicrosoftData() + : base(new SQLiteMSDataTestProvider()) + { + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteUpdateTests.cs b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteUpdateTests.cs new file mode 100644 index 00000000..5c1a4661 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SQLiteTests/SQLiteUpdateTests.cs @@ -0,0 +1,31 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SQLite +{ + public abstract partial class SQLiteUpdateTests : UpdateTests + { + protected SQLiteUpdateTests(TestProvider provider) + : base(provider) + { + } + + [Collection("SQLite.SystemData")] + public class SystemData : SQLiteUpdateTests + { + public SystemData() + : base(new SQLiteSystemDataTestProvider()) + { + } + } + + [Collection("SQLite.MicrosoftData")] + public class MicrosoftData : SQLiteUpdateTests + { + public MicrosoftData() + : base(new SQLiteMSDataTestProvider()) + { + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeDatabaseTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeDatabaseTests.cs new file mode 100644 index 00000000..0bc2da86 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeDatabaseTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SqlServerCe +{ + [Collection("SqlServerCe")] + public class SqlServerCeDatabaseTests : DatabaseTests + { + public SqlServerCeDatabaseTests() + : base(new SqlServerCeTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeDeleteTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeDeleteTests.cs new file mode 100644 index 00000000..cf1fd331 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeDeleteTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SqlServerCe +{ + [Collection("SqlServerCe")] + public class SqlServerCeDeleteTests : DeleteTests + { + public SqlServerCeDeleteTests() + : base(new SqlServerCeTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeExecuteTests.cs new file mode 100644 index 00000000..55fe27cb --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeExecuteTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SqlServerCe +{ + [Collection("SqlServerCe")] + public class SqlServerCeExecuteTests : ExecuteTests + { + public SqlServerCeExecuteTests() + : base(new SqlServerCeTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeInsertTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeInsertTests.cs new file mode 100644 index 00000000..97cf895a --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeInsertTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SqlServerCe +{ + [Collection("SqlServerCe")] + public class SqlServerCeInsertTests : InsertTests + { + public SqlServerCeInsertTests() + : base(new SqlServerCeTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeMiscellaneousTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeMiscellaneousTests.cs new file mode 100644 index 00000000..100f2ea0 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeMiscellaneousTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SqlServerCe +{ + [Collection("SqlServerCe")] + public class SqlServerCeMiscellaneousTests : MiscellaneousTests + { + public SqlServerCeMiscellaneousTests() + : base(new SqlServerCeTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCePreExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCePreExecuteTests.cs new file mode 100644 index 00000000..45e3b8e6 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCePreExecuteTests.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using System.Data; +using System.Linq; +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SqlServerCe +{ + [Collection("SqlServerCe")] + public class SqlServerCePreExecuteTests : PreExecuteTests + { + protected override IPreExecuteDatabaseProvider Provider => DB.Provider as PreExecuteDatabaseProvider; + + public SqlServerCePreExecuteTests() + : base(new PreExecuteTestProvider()) + { + Provider.ThrowExceptions = true; + } + + protected class PreExecuteTestProvider : SqlServerCeTestProvider + { + protected override IDatabase LoadFromConnectionName(string name) + => BuildFromConnectionName(name).UsingProvider().Create(); + } + + protected class PreExecuteDatabaseProvider : PetaPoco.Providers.SqlServerCEDatabaseProviders, IPreExecuteDatabaseProvider + { + public bool ThrowExceptions { get; set; } + public List Parameters { get; set; } = new List(); + + public override void PreExecute(IDbCommand cmd) + { + Parameters.Clear(); + + if (ThrowExceptions) + { + Parameters = cmd.Parameters.Cast().ToList(); + throw new PreExecuteException(); + } + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeQueryLinqTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeQueryLinqTests.cs new file mode 100644 index 00000000..2a9903c0 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeQueryLinqTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SqlServerCe +{ + [Collection("SqlServerCe")] + public class SqlServerCeQueryLinqTests : QueryLinqTests + { + public SqlServerCeQueryLinqTests() + : base(new SqlServerCeTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeQueryTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeQueryTests.cs similarity index 92% rename from PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeQueryTests.cs rename to PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeQueryTests.cs index 914da345..e5b3232b 100644 --- a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeQueryTests.cs +++ b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeQueryTests.cs @@ -1,15 +1,15 @@ using System; +using PetaPoco.Tests.Integration.Providers; using Shouldly; using Xunit; -#if MSSQLCE_TESTS_ENABLED -namespace PetaPoco.Tests.Integration.Databases.MSSQLCe +namespace PetaPoco.Tests.Integration.Databases.SqlServerCe { - [Collection("MssqlCe")] - public class MssqlCeQueryTests : BaseQueryTests + [Collection("SqlServerCe")] + public class SqlServerCeQueryTests : QueryTests { - public MssqlCeQueryTests() - : base(new MssqlCeDBTestProvider()) + public SqlServerCeQueryTests() + : base(new SqlServerCeTestProvider()) { } @@ -106,4 +106,3 @@ internal class TestClass public int? IntValue { get; set; } } } -#endif diff --git a/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeTriageTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeTriageTests.cs new file mode 100644 index 00000000..21fe1eb0 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeTriageTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SqlServerCe +{ + [Collection("SqlServerCe")] + public class SqlServerCeTriageTests : TriageTests + { + public SqlServerCeTriageTests() + : base(new SqlServerCeTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeUpdateTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeUpdateTests.cs new file mode 100644 index 00000000..ab2f37fe --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SqlServerCeTests/SqlServerCeUpdateTests.cs @@ -0,0 +1,14 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SqlServerCe +{ + [Collection("SqlServerCe")] + public class SqlServerCeUpdateTests : UpdateTests + { + public SqlServerCeUpdateTests() + : base(new SqlServerCeTestProvider()) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerDatabaseTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerDatabaseTests.cs new file mode 100644 index 00000000..e8130e87 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerDatabaseTests.cs @@ -0,0 +1,31 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SqlServer +{ + public abstract partial class SqlServerDatabaseTests : DatabaseTests + { + protected SqlServerDatabaseTests(TestProvider provider) + : base(provider) + { + } + + [Collection("SqlServer.SystemData")] + public class SystemData : SqlServerDatabaseTests + { + public SystemData() + : base(new SqlServerSystemDataTestProvider()) + { + } + } + + [Collection("SqlServer.MicrosoftData")] + public class MicrosoftData : SqlServerDatabaseTests + { + public MicrosoftData() + : base(new SqlServerMSDataTestProvider()) + { + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerDeleteTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerDeleteTests.cs new file mode 100644 index 00000000..997bc722 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerDeleteTests.cs @@ -0,0 +1,31 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SqlServer +{ + public abstract partial class SqlServerDeleteTests : DeleteTests + { + protected SqlServerDeleteTests(TestProvider provider) + : base(provider) + { + } + + [Collection("SqlServer.SystemData")] + public class SystemData : SqlServerDeleteTests + { + public SystemData() + : base(new SqlServerSystemDataTestProvider()) + { + } + } + + [Collection("SqlServer.MicrosoftData")] + public class MicrosoftData : SqlServerDeleteTests + { + public MicrosoftData() + : base(new SqlServerMSDataTestProvider()) + { + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerExecuteTests.cs new file mode 100644 index 00000000..fee3749b --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerExecuteTests.cs @@ -0,0 +1,31 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SqlServer +{ + public abstract partial class SqlServerExecuteTests : ExecuteTests + { + protected SqlServerExecuteTests(TestProvider provider) + : base(provider) + { + } + + [Collection("SqlServer.SystemData")] + public class SystemData : SqlServerExecuteTests + { + public SystemData() + : base(new SqlServerSystemDataTestProvider()) + { + } + } + + [Collection("SqlServer.MicrosoftData")] + public class MicrosoftData : SqlServerExecuteTests + { + public MicrosoftData() + : base(new SqlServerMSDataTestProvider()) + { + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerInsertTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerInsertTests.cs new file mode 100644 index 00000000..3f3344f3 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerInsertTests.cs @@ -0,0 +1,31 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SqlServer +{ + public abstract partial class SqlServerInsertTests : InsertTests + { + protected SqlServerInsertTests(TestProvider provider) + : base(provider) + { + } + + [Collection("SqlServer.SystemData")] + public class SystemData : SqlServerInsertTests + { + public SystemData() + : base(new SqlServerSystemDataTestProvider()) + { + } + } + + [Collection("SqlServer.MicrosoftData")] + public class MicrosoftData : SqlServerInsertTests + { + public MicrosoftData() + : base(new SqlServerMSDataTestProvider()) + { + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerMiscellaneousTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerMiscellaneousTests.cs new file mode 100644 index 00000000..2c833614 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerMiscellaneousTests.cs @@ -0,0 +1,31 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SqlServer +{ + public abstract partial class SqlServerMiscellaneousTests : MiscellaneousTests + { + protected SqlServerMiscellaneousTests(TestProvider provider) + : base(provider) + { + } + + [Collection("SqlServer.SystemData")] + public class SystemData : SqlServerMiscellaneousTests + { + public SystemData() + : base(new SqlServerSystemDataTestProvider()) + { + } + } + + [Collection("SqlServer.MicrosoftData")] + public class MicrosoftData : SqlServerMiscellaneousTests + { + public MicrosoftData() + : base(new SqlServerMSDataTestProvider()) + { + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerPreExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerPreExecuteTests.cs new file mode 100644 index 00000000..1572180f --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerPreExecuteTests.cs @@ -0,0 +1,86 @@ +using System.Collections.Generic; +using System.Data; +using System.Linq; +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SqlServer +{ + public abstract partial class SqlServerPreExecuteTests : PreExecuteTests + { + protected SqlServerPreExecuteTests(TestProvider provider) + : base(provider) + { + } + + [Collection("SqlServer.SystemData")] + public class SystemData : SqlServerPreExecuteTests + { + protected override IPreExecuteDatabaseProvider Provider => DB.Provider as PreExecuteDatabaseProvider; + + public SystemData() + : base(new PreExecuteTestProvider()) + { + Provider.ThrowExceptions = true; + } + + protected class PreExecuteTestProvider : SqlServerSystemDataTestProvider + { + protected override IDatabase LoadFromConnectionName(string name) + => BuildFromConnectionName(name).UsingProvider().Create(); + } + + protected class PreExecuteDatabaseProvider : PetaPoco.Providers.SqlServerDatabaseProvider, IPreExecuteDatabaseProvider + { + public bool ThrowExceptions { get; set; } + public List Parameters { get; set; } = new List(); + + public override void PreExecute(IDbCommand cmd) + { + Parameters.Clear(); + + if (ThrowExceptions) + { + Parameters = cmd.Parameters.Cast().ToList(); + throw new PreExecuteException(); + } + } + } + } + + [Collection("SqlServer.MicrosoftData")] + public class MicrosoftData : SqlServerPreExecuteTests + { + protected override IPreExecuteDatabaseProvider Provider => DB.Provider as PreExecuteDatabaseProvider; + + public MicrosoftData() + : base(new PreExecuteTestProvider()) + { + Provider.ThrowExceptions = true; + } + + protected class PreExecuteTestProvider : SqlServerMSDataTestProvider + { + protected override IDatabase LoadFromConnectionName(string name) + => BuildFromConnectionName(name).UsingProvider().Create(); + } + + protected class PreExecuteDatabaseProvider : PetaPoco.Providers.SqlServerMsDataDatabaseProvider, IPreExecuteDatabaseProvider + { + public bool ThrowExceptions { get; set; } + public List Parameters { get; set; } = new List(); + + public override void PreExecute(IDbCommand cmd) + { + Parameters.Clear(); + + if (ThrowExceptions) + { + Parameters = cmd.Parameters.Cast().ToList(); + throw new PreExecuteException(); + } + } + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlQueryLinqTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerQueryLinqTests.cs similarity index 51% rename from PetaPoco.Tests.Integration/Databases/MSSQL/MssqlQueryLinqTests.cs rename to PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerQueryLinqTests.cs index f20c64df..d878bf45 100644 --- a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlQueryLinqTests.cs +++ b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerQueryLinqTests.cs @@ -1,12 +1,12 @@ using System; -using PetaPoco.Tests.Integration.Models.MSSQL; +using PetaPoco.Tests.Integration.Models.SqlServer; +using PetaPoco.Tests.Integration.Providers; using Shouldly; using Xunit; -namespace PetaPoco.Tests.Integration.Databases.MSSQL +namespace PetaPoco.Tests.Integration.Databases.SqlServer { - [Collection("Mssql")] - public class MssqlQueryLinqTests : BaseQueryLinqTests + public abstract partial class SqlServerQueryLinqTests : QueryLinqTests { #region Test Data @@ -19,15 +19,15 @@ public class MssqlQueryLinqTests : BaseQueryLinqTests #endregion - public MssqlQueryLinqTests() - : base(new MssqlDBTestProvider()) + protected SqlServerQueryLinqTests(TestProvider provider) + : base(provider) { } [Fact] [Trait("Issue", "#242")] [Trait("DBFeature", "Schema")] - public void Exists_GivenPrimaryKeyMatchingOneRecordAndPocoWithSchema_ShouldBeTrue() + public virtual void Exists_GivenPrimaryKeyMatchingOneRecordAndPocoWithSchema_ShouldBeTrue() { var pk = DB.Insert(_storePerson); DB.Exists(pk).ShouldBeTrue(); @@ -36,7 +36,7 @@ public void Exists_GivenPrimaryKeyMatchingOneRecordAndPocoWithSchema_ShouldBeTru [Fact] [Trait("Issue", "#242")] [Trait("DBFeature", "Schema")] - public void Exists_GivenSqlStringMatchingOneRecordAndPocoWithSchema_ShouldBeTrue() + public virtual void Exists_GivenSqlStringMatchingOneRecordAndPocoWithSchema_ShouldBeTrue() { DB.Insert(_storePerson); DB.Exists($"WHERE {DB.Provider.EscapeSqlIdentifier("Age")} = @0", 18).ShouldBeTrue(); @@ -48,10 +48,29 @@ public void Exists_GivenSqlStringMatchingOneRecordAndPocoWithSchema_ShouldBeTrue [Trait("Issue", "#238")] [Trait("Issue", "#242")] [Trait("DBFeature", "Schema")] - public void Exists_Regression_GivenSqlStringMatchingOneRecordAndPocoWithSchema_ShouldBeTrue() + public virtual void Exists_Regression_GivenSqlStringMatchingOneRecordAndPocoWithSchema_ShouldBeTrue() { DB.Insert(_storePerson); DB.Exists($"{DB.Provider.EscapeSqlIdentifier("Age")} = @0", 18).ShouldBeTrue(); } + + + [Collection("SqlServer.SystemData")] + public class SystemData : SqlServerQueryLinqTests + { + public SystemData() + : base(new SqlServerSystemDataTestProvider()) + { + } + } + + [Collection("SqlServer.MicrosoftData")] + public class MicrosoftData : SqlServerQueryLinqTests + { + public MicrosoftData() + : base(new SqlServerMSDataTestProvider()) + { + } + } } } diff --git a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlQueryTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerQueryTests.cs similarity index 91% rename from PetaPoco.Tests.Integration/Databases/MSSQL/MssqlQueryTests.cs rename to PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerQueryTests.cs index 46bf689f..b3f98aa5 100644 --- a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlQueryTests.cs +++ b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerQueryTests.cs @@ -3,16 +3,16 @@ using System.Linq; using PetaPoco.Core; using PetaPoco.Tests.Integration.Models; +using PetaPoco.Tests.Integration.Providers; using Shouldly; using Xunit; -namespace PetaPoco.Tests.Integration.Databases.MSSQL +namespace PetaPoco.Tests.Integration.Databases.SqlServer { - [Collection("Mssql")] - public class MssqlQueryTests : BaseQueryTests + public abstract partial class SqlServerQueryTests : QueryTests { - public MssqlQueryTests() - : base(new MssqlDBTestProvider()) + protected SqlServerQueryTests(TestProvider provider) + : base(provider) { } @@ -20,7 +20,7 @@ public MssqlQueryTests() [Fact] [Trait("Issue", "#250")] [Trait("Issue", "#251")] - public void Query_ForPocoGivenSqlStringStartingWithSet_ShouldReturnValidPocoCollection() + public virtual void Query_ForPocoGivenSqlStringStartingWithSet_ShouldReturnValidPocoCollection() { AddOrders(12); var pd = PocoData.ForType(typeof(Order), DB.DefaultMapper); @@ -44,7 +44,7 @@ public void Query_ForPocoGivenSqlStringStartingWithSet_ShouldReturnValidPocoColl [Fact] [Trait("Issue", "#250")] [Trait("Issue", "#251")] - public void Query_ForPocoGivenSqlStringStartingWithDeclare_ShouldReturnValidPocoCollection() + public virtual void Query_ForPocoGivenSqlStringStartingWithDeclare_ShouldReturnValidPocoCollection() { AddOrders(12); var pd = PocoData.ForType(typeof(Order), DB.DefaultMapper); @@ -68,7 +68,7 @@ public void Query_ForPocoGivenSqlStringStartingWithDeclare_ShouldReturnValidPoco [Fact] [Trait("Issue", "#250")] [Trait("Issue", "#251")] - public void Query_ForPocoGivenSqlStringStartingWithWith_ShouldReturnValidPocoCollection() + public virtual void Query_ForPocoGivenSqlStringStartingWithWith_ShouldReturnValidPocoCollection() { AddOrders(12); var pd = PocoData.ForType(typeof(Order), DB.DefaultMapper); @@ -260,5 +260,24 @@ public override void QueryMultiple_ForMultiResultsSetWithMultiPoco_ShouldReturnV secondOrderLine.SellPrice.ShouldBe(19.98m); }); } + + + [Collection("SqlServer.SystemData")] + public class SystemData : SqlServerQueryTests + { + public SystemData() + : base(new SqlServerSystemDataTestProvider()) + { + } + } + + [Collection("SqlServer.MicrosoftData")] + public class MicrosoftData : SqlServerQueryTests + { + public MicrosoftData() + : base(new SqlServerMSDataTestProvider()) + { + } + } } } diff --git a/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerStoredProcTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerStoredProcTests.cs new file mode 100644 index 00000000..033cb406 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerStoredProcTests.cs @@ -0,0 +1,36 @@ +using System; +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SqlServer +{ + public abstract partial class SqlServerStoredProcTests : StoredProcTests + { + protected SqlServerStoredProcTests(TestProvider provider) + : base(provider) + { + } + + [Collection("SqlServer.SystemData")] + public class SystemData : SqlServerStoredProcTests + { + protected override Type DataParameterType => typeof(System.Data.SqlClient.SqlParameter); + + public SystemData() + : base(new SqlServerSystemDataTestProvider()) + { + } + } + + [Collection("SqlServer.MicrosoftData")] + public class MicrosoftData : SqlServerStoredProcTests + { + protected override Type DataParameterType => typeof(Microsoft.Data.SqlClient.SqlParameter); + + public MicrosoftData() + : base(new SqlServerMSDataTestProvider()) + { + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerTriageTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerTriageTests.cs new file mode 100644 index 00000000..caeb168f --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerTriageTests.cs @@ -0,0 +1,31 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SqlServer +{ + public abstract partial class SqlServerTriageTests : TriageTests + { + protected SqlServerTriageTests(TestProvider provider) + : base(provider) + { + } + + [Collection("SqlServer.SystemData")] + public class SystemData : SqlServerTriageTests + { + public SystemData() + : base(new SqlServerSystemDataTestProvider()) + { + } + } + + [Collection("SqlServer.MicrosoftData")] + public class MicrosoftData : SqlServerTriageTests + { + public MicrosoftData() + : base(new SqlServerMSDataTestProvider()) + { + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerUpdateTests.cs b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerUpdateTests.cs new file mode 100644 index 00000000..8f1ff877 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/SqlServerTests/SqlServerUpdateTests.cs @@ -0,0 +1,31 @@ +using PetaPoco.Tests.Integration.Providers; +using Xunit; + +namespace PetaPoco.Tests.Integration.Databases.SqlServer +{ + public abstract partial class SqlServerUpdateTests : UpdateTests + { + protected SqlServerUpdateTests(TestProvider provider) + : base(provider) + { + } + + [Collection("SqlServer.SystemData")] + public class SystemData : SqlServerUpdateTests + { + public SystemData() + : base(new SqlServerSystemDataTestProvider()) + { + } + } + + [Collection("SqlServer.MicrosoftData")] + public class MicrosoftData : SqlServerUpdateTests + { + public MicrosoftData() + : base(new SqlServerMSDataTestProvider()) + { + } + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteDatabaseTests.cs b/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteDatabaseTests.cs deleted file mode 100644 index c426dd7f..00000000 --- a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteDatabaseTests.cs +++ /dev/null @@ -1,34 +0,0 @@ -using System.Reflection; -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.Sqlite -{ - [Collection("Sqlite")] - public class SqliteDatabaseTests : BaseDatabaseTests - { - private readonly SqliteDBTestProvider _provider; - - public SqliteDatabaseTests() - : this(new SqliteDBTestProvider()) - { - } - - private SqliteDatabaseTests(SqliteDBTestProvider provider) - : base(provider) - { - _provider = provider; - } - - /// - /// This is required because we can't use the Mapper.* methods, as we're testing many different databases and it would apply Sqlite - /// logic incorrectly. - /// - protected override void AfterDbCreate(Database db) - { - base.AfterDbCreate(db); - - // ReSharper disable once PossibleNullReferenceException - db.GetType().GetField("_defaultMapper", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(db, _provider.GetDatabase().DefaultMapper); - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteDeleteTests.cs b/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteDeleteTests.cs deleted file mode 100644 index d2671238..00000000 --- a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteDeleteTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.Sqlite -{ - [Collection("Sqlite")] - public class SqliteDeleteTests : BaseDeleteTests - { - public SqliteDeleteTests() - : base(new SqliteDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteExecuteTests.cs b/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteExecuteTests.cs deleted file mode 100644 index 570280a4..00000000 --- a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteExecuteTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.Sqlite -{ - [Collection("Sqlite")] - public class SqliteExecuteTests : BaseExecuteTests - { - public SqliteExecuteTests() - : base(new SqliteDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteInsertTests.cs b/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteInsertTests.cs deleted file mode 100644 index bd5287b1..00000000 --- a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteInsertTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.Sqlite -{ - [Collection("Sqlite")] - public class SqliteInsertTests : BaseInsertTests - { - public SqliteInsertTests() - : base(new SqliteDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteMiscellaneousTests.cs b/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteMiscellaneousTests.cs deleted file mode 100644 index 44e76bb9..00000000 --- a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteMiscellaneousTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.Sqlite -{ - [Collection("Sqlite")] - public class SqliteMiscellaneousTests : BaseDatabase - { - public SqliteMiscellaneousTests() - : base(new SqliteDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteQueryLinqTests.cs b/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteQueryLinqTests.cs deleted file mode 100644 index accdaf8a..00000000 --- a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteQueryLinqTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.Sqlite -{ - [Collection("Sqlite")] - public class SqliteQueryLinqTests : BaseQueryLinqTests - { - public SqliteQueryLinqTests() - : base(new SqliteDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteTriageTests.cs b/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteTriageTests.cs deleted file mode 100644 index 9d727503..00000000 --- a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteTriageTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.Sqlite -{ - [Collection("Sqlite")] - public class SqliteTriageTests : BaseTriageTests - { - public SqliteTriageTests() - : base(new SqliteDBTestProvider()) - { - } - } -} diff --git a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteUpdateTests.cs b/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteUpdateTests.cs deleted file mode 100644 index fd82fe3a..00000000 --- a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteUpdateTests.cs +++ /dev/null @@ -1,13 +0,0 @@ -using Xunit; - -namespace PetaPoco.Tests.Integration.Databases.Sqlite -{ - [Collection("Sqlite")] - public class SqliteUpdateTests : BaseUpdateTests - { - public SqliteUpdateTests() - : base(new SqliteDBTestProvider()) - { - } - } -} \ No newline at end of file diff --git a/PetaPoco.Tests.Integration/Databases/BaseStoredProcTests.cs b/PetaPoco.Tests.Integration/Databases/StoredProcTests.cs similarity index 98% rename from PetaPoco.Tests.Integration/Databases/BaseStoredProcTests.cs rename to PetaPoco.Tests.Integration/Databases/StoredProcTests.cs index 90637bc0..94a0446a 100644 --- a/PetaPoco.Tests.Integration/Databases/BaseStoredProcTests.cs +++ b/PetaPoco.Tests.Integration/Databases/StoredProcTests.cs @@ -7,13 +7,13 @@ using Shouldly; using Xunit; -namespace PetaPoco.Tests.Integration.Databases +namespace PetaPoco.Tests.Integration { - public abstract class BaseStoredProcTests : BaseDatabase + public abstract class StoredProcTests : BaseDbContext { protected abstract Type DataParameterType { get; } - protected BaseStoredProcTests(DBTestProvider provider) + protected StoredProcTests(TestProvider provider) : base(provider) { AddPeople(6); diff --git a/PetaPoco.Tests.Integration/Databases/TriageTests.cs b/PetaPoco.Tests.Integration/Databases/TriageTests.cs new file mode 100644 index 00000000..cef5d9e0 --- /dev/null +++ b/PetaPoco.Tests.Integration/Databases/TriageTests.cs @@ -0,0 +1,10 @@ +namespace PetaPoco.Tests.Integration +{ + public abstract class TriageTests : BaseDbContext + { + protected TriageTests(TestProvider provider) + : base(provider) + { + } + } +} diff --git a/PetaPoco.Tests.Integration/Databases/BaseUpdateTests.cs b/PetaPoco.Tests.Integration/Databases/UpdateTests.cs similarity index 99% rename from PetaPoco.Tests.Integration/Databases/BaseUpdateTests.cs rename to PetaPoco.Tests.Integration/Databases/UpdateTests.cs index 5181ed1d..93571be2 100644 --- a/PetaPoco.Tests.Integration/Databases/BaseUpdateTests.cs +++ b/PetaPoco.Tests.Integration/Databases/UpdateTests.cs @@ -6,9 +6,9 @@ using Shouldly; using Xunit; -namespace PetaPoco.Tests.Integration.Databases +namespace PetaPoco.Tests.Integration { - public abstract class BaseUpdateTests : BaseDatabase + public abstract class UpdateTests : BaseDbContext { // TODO: Move to base class, combine with other test data #region Test Data @@ -45,7 +45,7 @@ public abstract class BaseUpdateTests : BaseDatabase #endregion - protected BaseUpdateTests(DBTestProvider provider) + protected UpdateTests(TestProvider provider) : base(provider) { } @@ -706,7 +706,7 @@ public async Task UpdateAsync_GivenTablePrimaryKeyNameAndDynamicType_ShouldNotTh #if !NETCOREAPP Should.NotThrow(async () => await Task.Run(() => DB.UpdateAsync("Note", "Id", (object)entity))); #else - Should.NotThrow(async () => await Task.Run(() => DB.UpdateAsync("Note", "Id", entity))); + await Should.NotThrowAsync(() => DB.UpdateAsync("Note", "Id", entity)); #endif } diff --git a/PetaPoco.Tests.Integration/Documentation/Delete.cs b/PetaPoco.Tests.Integration/Documentation/Delete.cs index 18d4ac29..b4e19f8a 100644 --- a/PetaPoco.Tests.Integration/Documentation/Delete.cs +++ b/PetaPoco.Tests.Integration/Documentation/Delete.cs @@ -1,18 +1,17 @@ using System; using PetaPoco.Core; -using PetaPoco.Tests.Integration.Databases; -using PetaPoco.Tests.Integration.Databases.MSSQL; using PetaPoco.Tests.Integration.Documentation.Pocos; +using PetaPoco.Tests.Integration.Providers; using Shouldly; using Xunit; namespace PetaPoco.Tests.Integration.Documentation { [Collection("Documentation")] - public class Deletes : BaseDatabase + public class DeleteTests : BaseDbContext { - public Deletes() - : base(new MssqlDBTestProvider()) + public DeleteTests() + : base(new SqlServerSystemDataTestProvider()) { PocoData.FlushCaches(); } diff --git a/PetaPoco.Tests.Integration/Documentation/Inserts.cs b/PetaPoco.Tests.Integration/Documentation/Insert.cs similarity index 88% rename from PetaPoco.Tests.Integration/Documentation/Inserts.cs rename to PetaPoco.Tests.Integration/Documentation/Insert.cs index cb729f7b..132220a7 100644 --- a/PetaPoco.Tests.Integration/Documentation/Inserts.cs +++ b/PetaPoco.Tests.Integration/Documentation/Insert.cs @@ -1,19 +1,18 @@ using System; using System.Linq; using PetaPoco.Core; -using PetaPoco.Tests.Integration.Databases; -using PetaPoco.Tests.Integration.Databases.MSSQL; using PetaPoco.Tests.Integration.Documentation.Pocos; +using PetaPoco.Tests.Integration.Providers; using Shouldly; using Xunit; namespace PetaPoco.Tests.Integration.Documentation { [Collection("Documentation")] - public class Inserts : BaseDatabase + public class InsertTests : BaseDbContext { - public Inserts() - : base(new MssqlDBTestProvider()) + public InsertTests() + : base(new SqlServerSystemDataTestProvider()) { PocoData.FlushCaches(); } @@ -33,11 +32,11 @@ public void Insert() // Get a clone/copy from the DB var clone = DB.Single(id); - // See, they are the same - clone.ShouldBe(person); + // The values in noteFromDb's column-mapped properties should be equal to the original poco's + clone.PropertiesShouldBe(person); // But they are not ReferenceEquals, as PetaPoco doesn't cache because it's a Micro-ORM. - person.Equals(clone).ShouldBeFalse(); + person.ShouldNotBeSameAs(clone); } [Fact] @@ -65,11 +64,11 @@ public void InsertAutoIncrement() // Get a clone/copy from the DB var clone = DB.Single(id); - // See, they are the same - clone.ShouldBe(order); + // The values in clone's column-mapped properties should be equal to the original poco's + clone.PropertiesShouldBe(order); // But they are not ReferenceEquals, as PetaPoco doesn't cache because it's a Micro-ORM. - order.Equals(clone).ShouldBeFalse(); + order.ShouldNotBeSameAs(clone); } [Fact] @@ -95,11 +94,11 @@ public void InsertToDifferentTable() // Note: we can't use auto select builder here because PetaPoco would create columns such as People.Id clone = DB.Query("SELECT * FROM [SpecificPeople] sp WHERE sp.[Id] = @0", id).Single(); - // See, they are the same - clone.ShouldBe(person); + // The values in clone's column-mapped properties should be equal to the original poco's + clone.PropertiesShouldBe(person); // But they are not ReferenceEquals, as PetaPoco doesn't cache because it's a Micro-ORM. - person.Equals(clone).ShouldBeFalse(); + person.ShouldNotBeSameAs(clone); } [Fact] @@ -146,11 +145,11 @@ [Text] NTEXT NOT NULL // Get a clone/copy from the DB var clone = DB.Query("SELECT * FROM [TBL_UnconventionalPocos] WHERE [PrimaryKey] = @0", id).Single(); - // See, they are the same - clone.ShouldBe(poco); + // The values in clone's column-mapped properties should be equal to the original poco's + clone.PropertiesShouldBe(poco); // But they are not ReferenceEquals, as PetaPoco doesn't cache because it's a Micro-ORM. - poco.Equals(clone).ShouldBeFalse(); + poco.ShouldNotBeSameAs(clone); } [Fact] @@ -189,11 +188,11 @@ [Text] NTEXT NOT NULL // Get a clone/copy from the DB var clone = DB.SingleOrDefault(id); - // See, they are the same - clone.ShouldBe(poco); + // The values in clone's column-mapped properties should be equal to the original poco's + clone.PropertiesShouldBe(poco); // But they are not ReferenceEquals, as PetaPoco doesn't cache because it's a Micro-ORM. - poco.Equals(clone).ShouldBeFalse(); + poco.ShouldNotBeSameAs(clone); } [Fact] @@ -218,7 +217,7 @@ [FileName] VARCHAR(255) NOT NULL // Note: Check out the named parameters - cool eh? var clone = DB.Query("SELECT * FROM [XFiles] WHERE [Id] = @Id", new { Id = id }).Single(); - // See, they are the same + // The values in clone's column-mapped properties should be equal to the original poco's id.ShouldBe((int)clone.Id); xfile.FileName.ShouldBe((string)clone.FileName); } @@ -246,7 +245,7 @@ [FileName] VARCHAR(255) NOT NULL // Note: Check out the named parameters - cool eh? var clone = DB.Query("SELECT * FROM [XFiles] WHERE [Id] = @Id", new { Id = id }).Single(); - // See, they are the same + // The values in clone's column-mapped properties should be equal to the original poco's id.ShouldBe((int)clone.Id); ((string)xfile.FileName).ShouldBe((string)clone.FileName); } diff --git a/PetaPoco.Tests.Integration/Documentation/Pocos/Order.cs b/PetaPoco.Tests.Integration/Documentation/Pocos/Order.cs index ace0d44a..caaa8c03 100644 --- a/PetaPoco.Tests.Integration/Documentation/Pocos/Order.cs +++ b/PetaPoco.Tests.Integration/Documentation/Pocos/Order.cs @@ -26,7 +26,7 @@ public class Order [Column("OrderStatus")] public OrderStatus Status { get; set; } - public void ShouldBe(Order other) + public void PropertiesShouldBe(Order other) { Id.ShouldBe(other.Id); PersonId.ShouldBe(other.PersonId); @@ -36,4 +36,4 @@ public void ShouldBe(Order other) CreatedBy.ShouldBe(other.CreatedBy); } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Documentation/Pocos/Person.cs b/PetaPoco.Tests.Integration/Documentation/Pocos/Person.cs index 3790aeee..f2ff32a1 100644 --- a/PetaPoco.Tests.Integration/Documentation/Pocos/Person.cs +++ b/PetaPoco.Tests.Integration/Documentation/Pocos/Person.cs @@ -25,7 +25,7 @@ public class Person [Ignore] public string NameAndAge => $"{Name} is of {Age}"; - public void ShouldBe(Person other) + public void PropertiesShouldBe(Person other) { Id.ShouldBe(other.Id); Name.ShouldBe(other.Name); @@ -34,4 +34,4 @@ public void ShouldBe(Person other) Dob.ShouldBe(other.Dob); } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Documentation/Pocos/UnconventionalPoco.cs b/PetaPoco.Tests.Integration/Documentation/Pocos/UnconventionalPoco.cs index 33382ea9..d5de141b 100644 --- a/PetaPoco.Tests.Integration/Documentation/Pocos/UnconventionalPoco.cs +++ b/PetaPoco.Tests.Integration/Documentation/Pocos/UnconventionalPoco.cs @@ -8,10 +8,10 @@ public class UnconventionalPoco public string Text { get; set; } - public void ShouldBe(UnconventionalPoco other) + public void PropertiesShouldBe(UnconventionalPoco other) { PrimaryKey.ShouldBe(other.PrimaryKey); Text.ShouldBe(other.Text); } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Documentation/Save.cs b/PetaPoco.Tests.Integration/Documentation/Save.cs index 8eb221b1..6c0bedb3 100644 --- a/PetaPoco.Tests.Integration/Documentation/Save.cs +++ b/PetaPoco.Tests.Integration/Documentation/Save.cs @@ -1,18 +1,17 @@ using System; using PetaPoco.Core; -using PetaPoco.Tests.Integration.Databases; -using PetaPoco.Tests.Integration.Databases.MSSQL; using PetaPoco.Tests.Integration.Documentation.Pocos; +using PetaPoco.Tests.Integration.Providers; using Shouldly; using Xunit; namespace PetaPoco.Tests.Integration.Documentation { [Collection("Documentation")] - public class Save : BaseDatabase + public class SaveTests : BaseDbContext { - public Save() - : base(new MssqlDBTestProvider()) + public SaveTests() + : base(new SqlServerSystemDataTestProvider()) { PocoData.FlushCaches(); } @@ -34,7 +33,7 @@ public void Save_Insert() // Fetch a new copy of note var noteFromDb = DB.Single(note.Id); - // They are the same + // The values in noteFromDb's column-mapped properties should be equal to the original poco's note.Id.ShouldBe(noteFromDb.Id); note.Text.ShouldBe(noteFromDb.Text); note.CreatedOn.Ticks.ShouldBe(noteFromDb.CreatedOn.Ticks); @@ -54,7 +53,7 @@ public void Save_Update() // Fetch a new copy of note var noteFromDb = DB.Single(note.Id); - // The note text is the same + // The values in noteFromDb's column-mapped properties should be equal to the original poco's note.Text.ShouldBe(noteFromDb.Text); note.Text.ShouldContain(" and this is my update"); } diff --git a/PetaPoco.Tests.Integration/Documentation/Updates.cs b/PetaPoco.Tests.Integration/Documentation/Update.cs similarity index 94% rename from PetaPoco.Tests.Integration/Documentation/Updates.cs rename to PetaPoco.Tests.Integration/Documentation/Update.cs index f00af65e..cc67c780 100644 --- a/PetaPoco.Tests.Integration/Documentation/Updates.cs +++ b/PetaPoco.Tests.Integration/Documentation/Update.cs @@ -1,19 +1,18 @@ using System; using System.Linq; using PetaPoco.Core; -using PetaPoco.Tests.Integration.Databases; -using PetaPoco.Tests.Integration.Databases.MSSQL; using PetaPoco.Tests.Integration.Documentation.Pocos; +using PetaPoco.Tests.Integration.Providers; using Shouldly; using Xunit; namespace PetaPoco.Tests.Integration.Documentation { [Collection("Documentation")] - public class Updates : BaseDatabase + public class UpdateTests : BaseDbContext { - public Updates() - : base(new MssqlDBTestProvider()) + public UpdateTests() + : base(new SqlServerSystemDataTestProvider()) { PocoData.FlushCaches(); } @@ -214,8 +213,8 @@ [Text] NTEXT NOT NULL // Get a clone/copy from the DB var clone = DB.SingleOrDefault(id); - // See, they are the same - clone.ShouldBe(poco); + // The values in clone's column-mapped properties should be equal to the original poco's + clone.PropertiesShouldBe(poco); // Update the original poco poco.Text += " some more text"; @@ -258,9 +257,9 @@ [FileName] VARCHAR(255) NOT NULL // Note: Check out the named parameters - cool eh? var clone = DB.Query("SELECT * FROM [XFiles] WHERE [Id] = @Id", new { Id = id }).Single(); - // See, they are the same - id.ShouldBe((int) clone.Id); - xfile.FileName.ShouldBe((string) clone.FileName); + // The values in clone's column-mapped properties should be equal to the original poco's + id.ShouldBe((int)clone.Id); + xfile.FileName.ShouldBe((string)clone.FileName); } [Fact] @@ -292,9 +291,9 @@ [FileName] VARCHAR(255) NOT NULL // Note: Check out the named parameters - cool eh? var clone = DB.Query("SELECT * FROM [XFiles] WHERE [Id] = @Id", new { Id = id }).Single(); - // See, they are the same - id.ShouldBe((int) clone.Id); - ((string) xfile.FileName).ShouldBe((string) clone.FileName); + // The values in clone's column-mapped properties should be equal to the original poco's + id.ShouldBe((int)clone.Id); + ((string)xfile.FileName).ShouldBe((string)clone.FileName); } } } diff --git a/PetaPoco.Tests.Integration/Models/MSAccess/JoinableOrdeLine.cs b/PetaPoco.Tests.Integration/Models/MSAccess/JoinableOrdeLine.cs index 2d6a4280..1a5ee799 100644 --- a/PetaPoco.Tests.Integration/Models/MSAccess/JoinableOrdeLine.cs +++ b/PetaPoco.Tests.Integration/Models/MSAccess/JoinableOrdeLine.cs @@ -1,6 +1,4 @@ -using System; -using System.Collections.Generic; -using Shouldly; +using Shouldly; namespace PetaPoco.Tests.Integration.Models.MSAccess { diff --git a/PetaPoco.Tests.Integration/Models/NoteNullablePrimary.cs b/PetaPoco.Tests.Integration/Models/NoteNullablePrimary.cs index 3eb9d591..a7201229 100644 --- a/PetaPoco.Tests.Integration/Models/NoteNullablePrimary.cs +++ b/PetaPoco.Tests.Integration/Models/NoteNullablePrimary.cs @@ -31,4 +31,4 @@ public void ShouldNotBe(NoteNullablePrimary other, bool sameIds) Text.ShouldNotBe(other.Text); } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Models/Order.cs b/PetaPoco.Tests.Integration/Models/Order.cs index 209a6bf8..e604a104 100644 --- a/PetaPoco.Tests.Integration/Models/Order.cs +++ b/PetaPoco.Tests.Integration/Models/Order.cs @@ -60,4 +60,4 @@ public void ShouldNotBe(Order other, bool sameIds) CreatedBy.ShouldNotBe(other.CreatedBy); } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Models/OrderLine.cs b/PetaPoco.Tests.Integration/Models/OrderLine.cs index fe7929a1..afd3b374 100644 --- a/PetaPoco.Tests.Integration/Models/OrderLine.cs +++ b/PetaPoco.Tests.Integration/Models/OrderLine.cs @@ -54,4 +54,4 @@ public void ShouldNotBe(OrderLine other, bool sameIds) SellPrice.ShouldNotBe(other.SellPrice); } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Models/OrderLineStatus.cs b/PetaPoco.Tests.Integration/Models/OrderLineStatus.cs index 71499ecf..704f608b 100644 --- a/PetaPoco.Tests.Integration/Models/OrderLineStatus.cs +++ b/PetaPoco.Tests.Integration/Models/OrderLineStatus.cs @@ -6,4 +6,4 @@ public enum OrderLineStatus : byte Backorder, Pending } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Models/OrderStatus.cs b/PetaPoco.Tests.Integration/Models/OrderStatus.cs index b3aa7563..f6a1b802 100644 --- a/PetaPoco.Tests.Integration/Models/OrderStatus.cs +++ b/PetaPoco.Tests.Integration/Models/OrderStatus.cs @@ -7,4 +7,4 @@ public enum OrderStatus Rejected, Deleted } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Models/Person.cs b/PetaPoco.Tests.Integration/Models/Person.cs index 6d2b5527..51f1ea65 100644 --- a/PetaPoco.Tests.Integration/Models/Person.cs +++ b/PetaPoco.Tests.Integration/Models/Person.cs @@ -51,4 +51,4 @@ public void ShouldNotBe(Person other, bool sameId) Dob.ShouldNotBe(other.Dob); } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Models/MSSQL/StorePerson.cs b/PetaPoco.Tests.Integration/Models/SqlServer/StorePerson.cs similarity index 85% rename from PetaPoco.Tests.Integration/Models/MSSQL/StorePerson.cs rename to PetaPoco.Tests.Integration/Models/SqlServer/StorePerson.cs index e763980f..8442fee8 100644 --- a/PetaPoco.Tests.Integration/Models/MSSQL/StorePerson.cs +++ b/PetaPoco.Tests.Integration/Models/SqlServer/StorePerson.cs @@ -1,6 +1,6 @@ using System; -namespace PetaPoco.Tests.Integration.Models.MSSQL +namespace PetaPoco.Tests.Integration.Models.SqlServer { [TableName("store.People")] [PrimaryKey("Id", AutoIncrement = false)] diff --git a/PetaPoco.Tests.Integration/Models/TransactionLog.cs b/PetaPoco.Tests.Integration/Models/TransactionLog.cs index ea11ac5f..2f2a1282 100644 --- a/PetaPoco.Tests.Integration/Models/TransactionLog.cs +++ b/PetaPoco.Tests.Integration/Models/TransactionLog.cs @@ -9,4 +9,4 @@ public class TransactionLog public DateTime CreatedOn { get; set; } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/PetaPoco.Tests.Integration.csproj b/PetaPoco.Tests.Integration/PetaPoco.Tests.Integration.csproj index 23c83b08..98567e99 100644 --- a/PetaPoco.Tests.Integration/PetaPoco.Tests.Integration.csproj +++ b/PetaPoco.Tests.Integration/PetaPoco.Tests.Integration.csproj @@ -1,4 +1,4 @@ - + net472;netcoreapp2.1 @@ -8,71 +8,87 @@ PetaPoco Collaborating Platypus Library + + false + true - + full - - - - - - - + - - - + + + - + - - - + + + + + + + + + + + + + + + + + + + + tlbimp + 0 + 6 + 00000600-0000-0010-8000-00aa006d2ea4 + 0 + false + true + + - - - + + - + - - - - - + + + + + - - + - - + - - - - - + + @@ -88,10 +104,4 @@ - - - Always - - - diff --git a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdDBTestProvider.cs b/PetaPoco.Tests.Integration/Providers/FirebirdTestProvider.cs similarity index 92% rename from PetaPoco.Tests.Integration/Databases/Firebird/FirebirdDBTestProvider.cs rename to PetaPoco.Tests.Integration/Providers/FirebirdTestProvider.cs index 705a5c6c..3c49ac44 100644 --- a/PetaPoco.Tests.Integration/Databases/Firebird/FirebirdDBTestProvider.cs +++ b/PetaPoco.Tests.Integration/Providers/FirebirdTestProvider.cs @@ -3,9 +3,9 @@ using FirebirdSql.Data.FirebirdClient; using FirebirdSql.Data.Isql; -namespace PetaPoco.Tests.Integration.Databases.Firebird +namespace PetaPoco.Tests.Integration.Providers { - public class FirebirdDBTestProvider : DBTestProvider + public class FirebirdTestProvider : TestProvider { protected override string ConnectionName => "Firebird"; diff --git a/PetaPoco.Tests.Integration/Providers/MSAccessTestProvider.cs b/PetaPoco.Tests.Integration/Providers/MSAccessTestProvider.cs new file mode 100644 index 00000000..ac2a5a32 --- /dev/null +++ b/PetaPoco.Tests.Integration/Providers/MSAccessTestProvider.cs @@ -0,0 +1,58 @@ +using System; +using System.Configuration; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; + +namespace PetaPoco.Tests.Integration.Providers +{ + public class MSAccessTestProvider : TestProvider + { + protected override string ConnectionName => "MSAccess"; + + protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.MSAccessBuildDatabase.sql"; + + public override IDatabase Execute() + { + if (!File.Exists(Path.Combine(Environment.CurrentDirectory, "PetaPoco.accdb"))) + { + var catalog = new ADOX.Catalog(); + + try + { + catalog.Create(ConfigurationManager.ConnectionStrings[ConnectionName].ConnectionString); + } + finally + { + Marshal.ReleaseComObject(catalog); + } + } + + return base.Execute(); + } + + public override void ExecuteBuildScript(IDatabase database, string script) + { + script.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToList().ForEach(s => + { + if (string.IsNullOrEmpty(s) || s.StartsWith("--")) + return; + + if (s.StartsWith("DROP")) + { + try + { + base.ExecuteBuildScript(database, s); + } + catch + { + } + + return; + } + + base.ExecuteBuildScript(database, s); + }); + } + } +} diff --git a/PetaPoco.Tests.Integration/Providers/MariaDBTestProvider.cs b/PetaPoco.Tests.Integration/Providers/MariaDBTestProvider.cs new file mode 100644 index 00000000..2952115c --- /dev/null +++ b/PetaPoco.Tests.Integration/Providers/MariaDBTestProvider.cs @@ -0,0 +1,9 @@ +namespace PetaPoco.Tests.Integration.Providers +{ + public class MariaDBTestProvider : TestProvider + { + protected override string ConnectionName => "MariaDB"; + + protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.MariaDBBuildDatabase.sql"; + } +} diff --git a/PetaPoco.Tests.Integration/Providers/MySqlConnectorTestProvider.cs b/PetaPoco.Tests.Integration/Providers/MySqlConnectorTestProvider.cs new file mode 100644 index 00000000..e4d12794 --- /dev/null +++ b/PetaPoco.Tests.Integration/Providers/MySqlConnectorTestProvider.cs @@ -0,0 +1,9 @@ +namespace PetaPoco.Tests.Integration.Providers +{ + public class MySqlConnectorTestProvider : TestProvider + { + protected override string ConnectionName => "MySqlConnector"; + + protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.MySqlBuildDatabase.sql"; + } +} diff --git a/PetaPoco.Tests.Integration/Providers/MySqlTestProvider.cs b/PetaPoco.Tests.Integration/Providers/MySqlTestProvider.cs new file mode 100644 index 00000000..f4d74736 --- /dev/null +++ b/PetaPoco.Tests.Integration/Providers/MySqlTestProvider.cs @@ -0,0 +1,9 @@ +namespace PetaPoco.Tests.Integration.Providers +{ + public class MySqlTestProvider : TestProvider + { + protected override string ConnectionName => "MySql"; + + protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.MySqlBuildDatabase.sql"; + } +} diff --git a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresDBTestProvider.cs b/PetaPoco.Tests.Integration/Providers/PostgresTestProvider.cs similarity index 63% rename from PetaPoco.Tests.Integration/Databases/Postgres/PostgresDBTestProvider.cs rename to PetaPoco.Tests.Integration/Providers/PostgresTestProvider.cs index 7c4a6edc..2cde690d 100644 --- a/PetaPoco.Tests.Integration/Databases/Postgres/PostgresDBTestProvider.cs +++ b/PetaPoco.Tests.Integration/Providers/PostgresTestProvider.cs @@ -1,9 +1,9 @@ -namespace PetaPoco.Tests.Integration.Databases.Postgres +namespace PetaPoco.Tests.Integration.Providers { - public class PostgresDBTestProvider : DBTestProvider + public class PostgresTestProvider : TestProvider { protected override string ConnectionName => "Postgres"; protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.PostgresBuildDatabase.sql"; } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Providers/SQLiteMSDataTestProvider.cs b/PetaPoco.Tests.Integration/Providers/SQLiteMSDataTestProvider.cs new file mode 100644 index 00000000..c06fce0e --- /dev/null +++ b/PetaPoco.Tests.Integration/Providers/SQLiteMSDataTestProvider.cs @@ -0,0 +1,12 @@ +using System; +using System.Linq; + +namespace PetaPoco.Tests.Integration.Providers +{ + public class SQLiteMSDataTestProvider : SQLiteTestProvider + { + protected override string ConnectionName => "SQLiteMSData"; + + protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.SQLiteBuildDatabase.sql"; + } +} diff --git a/PetaPoco.Tests.Integration/Providers/SQLiteSystemDataTestProvider.cs b/PetaPoco.Tests.Integration/Providers/SQLiteSystemDataTestProvider.cs new file mode 100644 index 00000000..841180a9 --- /dev/null +++ b/PetaPoco.Tests.Integration/Providers/SQLiteSystemDataTestProvider.cs @@ -0,0 +1,12 @@ +using System; +using System.Linq; + +namespace PetaPoco.Tests.Integration.Providers +{ + public class SQLiteSystemDataTestProvider : SQLiteTestProvider + { + protected override string ConnectionName => "SQLite"; + + protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.SQLiteBuildDatabase.sql"; + } +} diff --git a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteDBTestProvider.cs b/PetaPoco.Tests.Integration/Providers/SQLiteTestProvider.cs similarity index 85% rename from PetaPoco.Tests.Integration/Databases/Sqlite/SqliteDBTestProvider.cs rename to PetaPoco.Tests.Integration/Providers/SQLiteTestProvider.cs index 8d49ef88..a83e995a 100644 --- a/PetaPoco.Tests.Integration/Databases/Sqlite/SqliteDBTestProvider.cs +++ b/PetaPoco.Tests.Integration/Providers/SQLiteTestProvider.cs @@ -1,14 +1,10 @@ using System; using System.Linq; -namespace PetaPoco.Tests.Integration.Databases.Sqlite +namespace PetaPoco.Tests.Integration.Providers { - public class SqliteDBTestProvider : DBTestProvider + public abstract class SQLiteTestProvider : TestProvider { - protected override string ConnectionName => "sqlite"; - - protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.SqliteBuildDatabase.sql"; - public IDatabase GetDatabase() => Database; protected override IDatabaseBuildConfiguration BuildFromConnectionName(string name) diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeDBTestProvider.cs b/PetaPoco.Tests.Integration/Providers/SqlServerCeTestProvider.cs similarity index 84% rename from PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeDBTestProvider.cs rename to PetaPoco.Tests.Integration/Providers/SqlServerCeTestProvider.cs index 4d792f5b..cf668fa7 100644 --- a/PetaPoco.Tests.Integration/Databases/MSSQLCe/MssqlCeDBTestProvider.cs +++ b/PetaPoco.Tests.Integration/Providers/SqlServerCeTestProvider.cs @@ -4,16 +4,15 @@ using System.IO; using System.Linq; -#if MSSQLCE_TESTS_ENABLED -namespace PetaPoco.Tests.Integration.Databases.MSSQLCe +namespace PetaPoco.Tests.Integration.Providers { - public class MssqlCeDBTestProvider : DBTestProvider + public class SqlServerCeTestProvider : TestProvider { - protected override string ConnectionName => "mssqlce"; + protected override string ConnectionName => "SqlServerCe"; - protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.MSSQLCeBuildDatabase.sql"; + protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.SqlServerCeBuildDatabase.sql"; - public MssqlCeDBTestProvider() + public SqlServerCeTestProvider() { // Hack: Nuget package is old and doesn't support newer content // ReSharper disable AssignNullToNotNullAttribute @@ -35,7 +34,7 @@ public override IDatabase Execute() { if (!File.Exists(Path.Combine(Environment.CurrentDirectory, "petapoco.sdf"))) { - using (var engine = new SqlCeEngine(ConfigurationManager.ConnectionStrings["mssqlce"].ConnectionString)) + using (var engine = new SqlCeEngine(ConfigurationManager.ConnectionStrings["SqlServerCe"].ConnectionString)) { engine.CreateDatabase(); } @@ -48,7 +47,7 @@ public override void ExecuteBuildScript(IDatabase database, string script) { script.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(s => s.Trim()).ToList().ForEach(s => { - if (String.IsNullOrEmpty(s) || s.StartsWith("--")) + if (string.IsNullOrEmpty(s) || s.StartsWith("--")) return; if (s.StartsWith("DROP")) @@ -69,4 +68,3 @@ public override void ExecuteBuildScript(IDatabase database, string script) } } } -#endif diff --git a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataDBTestProvider.cs b/PetaPoco.Tests.Integration/Providers/SqlServerMSDataTestProvider.cs similarity index 58% rename from PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataDBTestProvider.cs rename to PetaPoco.Tests.Integration/Providers/SqlServerMSDataTestProvider.cs index c3a2df5f..896b3619 100644 --- a/PetaPoco.Tests.Integration/Databases/MSSQLMsData/MssqlMsDataDBTestProvider.cs +++ b/PetaPoco.Tests.Integration/Providers/SqlServerMSDataTestProvider.cs @@ -1,14 +1,14 @@ using System; using System.Linq; -namespace PetaPoco.Tests.Integration.Databases.MSSQLMsData +namespace PetaPoco.Tests.Integration.Providers { - public class MssqlMsDataDBTestProvider : DBTestProvider + public class SqlServerMSDataTestProvider : TestProvider { - private string _connectionName = "mssqlmsdata"; + private string _connectionName = "SqlServerMSData"; protected override string ConnectionName => _connectionName; - protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.MSSQLBuildDatabase.sql"; + protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.SqlServerBuildDatabase.sql"; public override IDatabase Execute() { @@ -23,9 +23,9 @@ public override void ExecuteBuildScript(IDatabase database, string script) private void EnsureDatabaseExists() { - _connectionName = "mssqlmsdata_builder"; - Database.Execute("IF(db_id(N'PetaPocoMsData') IS NULL) BEGIN CREATE DATABASE [PetaPocoMsData] END"); - _connectionName = "mssqlmsdata"; + _connectionName = "SqlServerMSData_Builder"; + Database.Execute("IF(db_id(N'PetaPocoMSData') IS NULL) BEGIN CREATE DATABASE [PetaPocoMSData] END"); + _connectionName = "SqlServerMSData"; } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlDBTestProvider.cs b/PetaPoco.Tests.Integration/Providers/SqlServerSystemDataTestProvider.cs similarity index 69% rename from PetaPoco.Tests.Integration/Databases/MSSQL/MssqlDBTestProvider.cs rename to PetaPoco.Tests.Integration/Providers/SqlServerSystemDataTestProvider.cs index ae3d7473..6e741c5c 100644 --- a/PetaPoco.Tests.Integration/Databases/MSSQL/MssqlDBTestProvider.cs +++ b/PetaPoco.Tests.Integration/Providers/SqlServerSystemDataTestProvider.cs @@ -1,14 +1,14 @@ using System; using System.Linq; -namespace PetaPoco.Tests.Integration.Databases.MSSQL +namespace PetaPoco.Tests.Integration.Providers { - public class MssqlDBTestProvider : DBTestProvider + public class SqlServerSystemDataTestProvider : TestProvider { - private string _connectionName = "mssql"; + private string _connectionName = "SqlServer"; protected override string ConnectionName => _connectionName; - protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.MSSQLBuildDatabase.sql"; + protected override string ScriptResourceName => "PetaPoco.Tests.Integration.Scripts.SqlServerBuildDatabase.sql"; public override IDatabase Execute() { @@ -23,9 +23,9 @@ public override void ExecuteBuildScript(IDatabase database, string script) private void EnsureDatabaseExists() { - _connectionName = "mssql_builder"; + _connectionName = "SqlServer_Builder"; Database.Execute("IF(db_id(N'PetaPoco') IS NULL) BEGIN CREATE DATABASE[PetaPoco] END"); - _connectionName = "mssql"; + _connectionName = "SqlServer"; } } -} \ No newline at end of file +} diff --git a/PetaPoco.Tests.Integration/Databases/DBTestProvider.cs b/PetaPoco.Tests.Integration/Providers/TestProvider.cs similarity index 71% rename from PetaPoco.Tests.Integration/Databases/DBTestProvider.cs rename to PetaPoco.Tests.Integration/Providers/TestProvider.cs index 4f30ba44..0c81eeb3 100644 --- a/PetaPoco.Tests.Integration/Databases/DBTestProvider.cs +++ b/PetaPoco.Tests.Integration/Providers/TestProvider.cs @@ -3,9 +3,9 @@ using System.IO; using System.Text; -namespace PetaPoco.Tests.Integration.Databases +namespace PetaPoco.Tests.Integration { - public abstract class DBTestProvider : IDisposable + public abstract class TestProvider : IDisposable { public string ProviderName => GetProviderName(ConnectionName); @@ -38,28 +38,28 @@ public virtual void ExecuteBuildScript(IDatabase database, string script) database.Execute(script); } - protected virtual IDatabaseBuildConfiguration BuildFromConnectionName(string name) + protected virtual IDatabase LoadFromConnectionName(string connectionName) + { + return BuildFromConnectionName(connectionName).Create(); + } + + protected virtual IDatabaseBuildConfiguration BuildFromConnectionName(string connectionName) { #if NETCOREAPP return DatabaseConfiguration.Build() - .UsingConnectionString(AppSetting.Instance.ConnectionStringFor(name).ConnectionString) - .UsingProviderName(AppSetting.Instance.ConnectionStringFor(name).ProviderName); + .UsingConnectionString(AppSetting.Instance.ConnectionStringFor(connectionName).ConnectionString) + .UsingProviderName(AppSetting.Instance.ConnectionStringFor(connectionName).ProviderName); #else - return DatabaseConfiguration.Build().UsingConnectionStringName(name); + return DatabaseConfiguration.Build().UsingConnectionStringName(connectionName); #endif } - protected virtual IDatabase LoadFromConnectionName(string name) - { - return BuildFromConnectionName(name).Create(); - } - - public string GetProviderName(string name) + protected string GetProviderName(string connectionName) { #if NETCOREAPP - return AppSetting.Instance.ConnectionStringFor(name).ProviderName; + return AppSetting.Instance.ConnectionStringFor(connectionName).ProviderName; #else - return ConfigurationManager.ConnectionStrings[name].ProviderName; + return ConfigurationManager.ConnectionStrings[connectionName].ProviderName; #endif } } diff --git a/PetaPoco.Tests.Integration/Scripts/MSAccessBuildDatabase.sql b/PetaPoco.Tests.Integration/Scripts/MSAccessBuildDatabase.sql index 6dc1132e..63259fbd 100644 --- a/PetaPoco.Tests.Integration/Scripts/MSAccessBuildDatabase.sql +++ b/PetaPoco.Tests.Integration/Scripts/MSAccessBuildDatabase.sql @@ -8,7 +8,7 @@ DROP TABLE [TransactionLogs]; DROP TABLE [Note]; CREATE TABLE [People] ( - [Id] TEXT NOT NULL PRIMARY KEY, + [Id] MEMO NOT NULL PRIMARY KEY, [FullName] MEMO, [Age] Long NOT NULL, [Height] INTEGER NOT NULL, @@ -17,7 +17,7 @@ CREATE TABLE [People] ( CREATE TABLE [Orders] ( [Id] AUTOINCREMENT PRIMARY KEY, - [PersonId] TEXT CONSTRAINT FK_O_PersonId REFERENCES [People](Id), + [PersonId] MEMO CONSTRAINT FK_O_PersonId REFERENCES [People](Id), [PoNumber] MEMO NOT NULL, [OrderStatus] INTEGER NOT NULL, [CreatedOn] Datetime NOT NULL, @@ -33,7 +33,7 @@ CREATE TABLE [OrderLines] ( ); CREATE TABLE [SpecificPeople] ( - [Id] TEXT NOT NULL PRIMARY KEY, + [Id] MEMO NOT NULL PRIMARY KEY, [FullName] MEMO, [Age] Long NOT NULL, [Height] INTEGER NOT NULL, @@ -42,7 +42,7 @@ CREATE TABLE [SpecificPeople] ( CREATE TABLE [SpecificOrders] ( [Id] AUTOINCREMENT PRIMARY KEY, - [PersonId] TEXT CONSTRAINT FK_SO_PersonId REFERENCES [SpecificPeople](Id), + [PersonId] MEMO CONSTRAINT FK_SO_PersonId REFERENCES [SpecificPeople](Id), [PoNumber] MEMO NOT NULL, [OrderStatus] INTEGER NOT NULL, [CreatedOn] Datetime NOT NULL, diff --git a/PetaPoco.Tests.Integration/Scripts/MariaDbBuildDatabase.sql b/PetaPoco.Tests.Integration/Scripts/MariaDBBuildDatabase.sql similarity index 100% rename from PetaPoco.Tests.Integration/Scripts/MariaDbBuildDatabase.sql rename to PetaPoco.Tests.Integration/Scripts/MariaDBBuildDatabase.sql diff --git a/PetaPoco.Tests.Integration/Scripts/SqliteBuildDatabase.sql b/PetaPoco.Tests.Integration/Scripts/SQLiteBuildDatabase.sql similarity index 100% rename from PetaPoco.Tests.Integration/Scripts/SqliteBuildDatabase.sql rename to PetaPoco.Tests.Integration/Scripts/SQLiteBuildDatabase.sql diff --git a/PetaPoco.Tests.Integration/Scripts/MSSQLBuildDatabase.sql b/PetaPoco.Tests.Integration/Scripts/SqlServerBuildDatabase.sql similarity index 100% rename from PetaPoco.Tests.Integration/Scripts/MSSQLBuildDatabase.sql rename to PetaPoco.Tests.Integration/Scripts/SqlServerBuildDatabase.sql diff --git a/PetaPoco.Tests.Integration/Scripts/MSSQLCeBuildDatabase.sql b/PetaPoco.Tests.Integration/Scripts/SqlServerCeBuildDatabase.sql similarity index 100% rename from PetaPoco.Tests.Integration/Scripts/MSSQLCeBuildDatabase.sql rename to PetaPoco.Tests.Integration/Scripts/SqlServerCeBuildDatabase.sql diff --git a/PetaPoco.Tests.Integration/app.config b/PetaPoco.Tests.Integration/app.config index ad2cfc2b..f9cbe75e 100644 --- a/PetaPoco.Tests.Integration/app.config +++ b/PetaPoco.Tests.Integration/app.config @@ -3,18 +3,19 @@ - - - - - - - - - + + + + + + + + + - - + + + diff --git a/PetaPoco.Tests.Integration/appsettings.json b/PetaPoco.Tests.Integration/appsettings.json index aaf4146c..d7098a89 100644 --- a/PetaPoco.Tests.Integration/appsettings.json +++ b/PetaPoco.Tests.Integration/appsettings.json @@ -2,58 +2,63 @@ "App": { "ConnectionStrings": [ { - "Name": "postgres", + "Name": "Postgres", "ConnectionString": "Host=localhost;Username=petapoco;Password=petapoco;Database=petapoco;Port=5001", "ProviderName": "Npgsql" }, { - "Name": "firebird", + "Name": "Firebird", "ConnectionString": "User=SYSDBA;Password=petapoco;Database=/firebird/data/petapoco.fdb;DataSource=localhost;Port=5004;ServerType=0;Charset=NONE;Pooling=false", "ProviderName": "FirebirdSql.Data.FirebirdClient" }, { - "Name": "mysql", + "Name": "MySql", "ConnectionString": "Server=localhost;Uid=petapoco;Pwd=petapoco;Database=petapoco;Port=5002", "ProviderName": "MySql.Data.MySqlClient" }, { - "Name": "mysqlconnector", + "Name": "MySqlConnector", "ConnectionString": "Server=localhost;Uid=petapoco;Pwd=petapoco;Database=petapoco;Port=5005", "ProviderName": "MySqlConnector" }, { - "Name": "mariadb", + "Name": "MariaDB", "ConnectionString": "Server=localhost;Uid=petapoco;Pwd=petapoco;Database=petapoco;Port=5003;SslMode=none", "ProviderName": "MySql.Data.MySqlClient" }, { - "Name": "mssql_builder", + "Name": "SqlServer_Builder", "ConnectionString": "Data Source=localhost,5006;User ID=sa;Password=pAtAp0c8", "ProviderName": "System.Data.SqlClient" }, { - "Name": "mssql", + "Name": "SqlServer", "ConnectionString": "Data Source=localhost,5006;Initial Catalog=PetaPoco;User ID=sa;Password=pAtAp0c8", "ProviderName": "System.Data.SqlClient" }, { - "Name": "mssqlmsdata_builder", + "Name": "SqlServerMSData_Builder", "ConnectionString": "Data Source=localhost,5007;User ID=sa;Password=pAtAp0c8", "ProviderName": "Microsoft.Data.SqlClient" }, { - "Name": "mssqlmsdata", - "ConnectionString": "Data Source=localhost,5007;Initial Catalog=PetaPocoMsData;User ID=sa;Password=pAtAp0c8", + "Name": "SqlServerMSData", + "ConnectionString": "Data Source=localhost,5007;Initial Catalog=PetaPocoMSData;User ID=sa;Password=pAtAp0c8", "ProviderName": "Microsoft.Data.SqlClient" }, { - "Name": "sqlite", + "Name": "SQLite", "ConnectionString": "Data Source=PetaPoco.sqlite;Pooling=True;Max Pool Size=100", "ProviderName": "System.Data.SQLite" }, { - "Name": "msaccess", - "ConnectionString": "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|DataSources/petapoco.accdb", + "Name": "SQLiteMSData", + "ConnectionString": "Data Source=PetaPocoMSData.sqlite;Pooling=True;Max Pool Size=100", + "ProviderName": "Microsoft.Data.SQLite" + }, + { + "Name": "MSAccess", + "ConnectionString": "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=PetaPoco.accdb", "ProviderName": "OleDb" } ] diff --git a/PetaPoco.Tests.Unit/PetaPoco.Tests.Unit.csproj b/PetaPoco.Tests.Unit/PetaPoco.Tests.Unit.csproj index 26c1f2b5..3f58f518 100644 --- a/PetaPoco.Tests.Unit/PetaPoco.Tests.Unit.csproj +++ b/PetaPoco.Tests.Unit/PetaPoco.Tests.Unit.csproj @@ -8,32 +8,32 @@ PetaPoco Collaborating Platypus Library + + false + true - + - + - - - - - - - - - - - - - + + + + + + + + + + - \ No newline at end of file + diff --git a/PetaPoco/Core/DatabaseProvider.cs b/PetaPoco/Core/DatabaseProvider.cs index 65911993..6485a169 100644 --- a/PetaPoco/Core/DatabaseProvider.cs +++ b/PetaPoco/Core/DatabaseProvider.cs @@ -14,9 +14,13 @@ namespace PetaPoco.Core { /// - /// The DatabaseProvider class defines a base implementation for database Provider classes, and provides common defaults used by - /// different database management systems. + /// Provides an abstract base class for database providers. This class implements common functionality and provides default behavior for + /// specialized database providers. /// + /// + /// This class includes methods for database-specific operations like parameter handling, SQL escaping, and paging, among others. + /// Derived classes should override these methods to implement behavior specific to the database they target. + /// public abstract class DatabaseProvider : IProvider { private static readonly ConcurrentDictionary customProviders = new ConcurrentDictionary(); @@ -101,7 +105,7 @@ protected DbProviderFactory GetFactory(params string[] assemblyQualifiedNames) if (ft == null) throw new ArgumentException($"Could not load the {GetType().Name} DbProviderFactory."); - return (DbProviderFactory) ft.GetField("Instance").GetValue(null); + return (DbProviderFactory)ft.GetField("Instance").GetValue(null); } /// diff --git a/PetaPoco/Core/IProvider.cs b/PetaPoco/Core/IProvider.cs index 3ec7ca57..4f724173 100644 --- a/PetaPoco/Core/IProvider.cs +++ b/PetaPoco/Core/IProvider.cs @@ -9,7 +9,7 @@ namespace PetaPoco.Core { /// - /// Represents a contract for a database type provider. + /// Defines the contract for database providers that expose functionality for connecting to various types of databases. /// public interface IProvider { diff --git a/PetaPoco/OracleProvider.cs b/PetaPoco/OracleProvider.cs index 9988e87f..80f47cc9 100644 --- a/PetaPoco/OracleProvider.cs +++ b/PetaPoco/OracleProvider.cs @@ -5,13 +5,13 @@ namespace PetaPoco { /// - /// Pprovides an implementation of for early versions of the Oracle drivers that don't include it. + /// Provides an implementation of for Oracle databases using the unmanaged Oracle Data Provider. /// /// - /// For later versions of Oracle, the standard OracleProviderFactory class should work fine. - /// Uses reflection to load Oracle.DataAccess assembly and in-turn create connections and commands. - /// Thanks to Adam Schroder (@schotime) for this. - /// Currently untested. + /// This provider uses the "Oracle.DataAccess.Client" ADO.NET driver for data access. For later versions of Oracle, the managed class should work fine. Uses reflection to load "Oracle.DataAccess" assembly and in-turn + /// create connections and commands. + /// Thanks to Adam Schroder (@schotime) for this. Currently untested. /// /// /// @@ -69,7 +69,7 @@ public OracleProvider() /// A new . public override DbConnection CreateConnection() { - return (DbConnection) Activator.CreateInstance(_connectionType); + return (DbConnection)Activator.CreateInstance(_connectionType); } /// @@ -78,7 +78,7 @@ public override DbConnection CreateConnection() /// A new . public override DbCommand CreateCommand() { - DbCommand command = (DbCommand) Activator.CreateInstance(_commandType); + DbCommand command = (DbCommand)Activator.CreateInstance(_commandType); var oracleCommandBindByName = _commandType.GetProperty("BindByName"); oracleCommandBindByName.SetValue(command, true, null); diff --git a/PetaPoco/PetaPoco.csproj b/PetaPoco/PetaPoco.csproj index c0068d35..b5746e23 100644 --- a/PetaPoco/PetaPoco.csproj +++ b/PetaPoco/PetaPoco.csproj @@ -11,7 +11,7 @@ https://github.com/CollaboratingPlatypus/PetaPoco https://github.com/CollaboratingPlatypus/PetaPoco/blob/master/LICENSE.txt https://github.com/CollaboratingPlatypus/PetaPoco - Peta Poco Peta-Poco PetaPoco ORM-Micro Micro-ORM ORM ormmicro MVC MVC4 MVC5 MVC6 MySql Postgres MSSQL Database DAL SQL Easy + PetaPoco Peta Poco Peta-Poco ORM-Micro Micro-ORM ORM ORMMicro MicroORM MySql MariaDB MySqlConnector Firebird SQLite Postgres PostgreSQL SqlServer MSSQL Oracle OracleDatabase RDBMS DBMS Relational Database DAL SQL Easy MVC MVC4 MVC5 MVC6 https://raw.githubusercontent.com/CollaboratingPlatypus/PetaPoco/master/Media/Logo2/PetaPocoLogo2Nuget.png false PetaPoco.Compiled diff --git a/PetaPoco/Providers/FirebirdDatabaseProvider.cs b/PetaPoco/Providers/FirebirdDatabaseProvider.cs index 51d9e6bc..5c2fdbad 100644 --- a/PetaPoco/Providers/FirebirdDatabaseProvider.cs +++ b/PetaPoco/Providers/FirebirdDatabaseProvider.cs @@ -10,10 +10,14 @@ namespace PetaPoco.Providers { - // TODO: It irks the ¢®@₱ out of me that the Firebird DBProvider class name is the only one that improperly appends "Db" after the provider name. + // TODO: Rename class: FirebirdDatabaseProvider + /// - /// Provides a specific implementation of the class for Firebird. + /// Provides an implementation of for Firebird databases. /// + /// + /// This provider uses the "FirebirdSql.Data.FirebirdClient" ADO.NET driver for data access. + /// public class FirebirdDbDatabaseProvider : DatabaseProvider { /// diff --git a/PetaPoco/Providers/MsAccessDbDatabaseProvider.cs b/PetaPoco/Providers/MSAccessDatabaseProvider.cs similarity index 78% rename from PetaPoco/Providers/MsAccessDbDatabaseProvider.cs rename to PetaPoco/Providers/MSAccessDatabaseProvider.cs index 5f4c89c0..5066b392 100644 --- a/PetaPoco/Providers/MsAccessDbDatabaseProvider.cs +++ b/PetaPoco/Providers/MSAccessDatabaseProvider.cs @@ -10,9 +10,14 @@ namespace PetaPoco.Providers { + // TODO: Rename class: MSAccessDatabaseProvider + /// - /// Provides a specific implementation of the class for Microsoft Access. + /// Provides an implementation of for Microsoft Access databases. /// + /// + /// This provider uses the "System.Data.OleDb" ADO.NET driver for data access. + /// public class MsAccessDbDatabaseProvider : DatabaseProvider { /// @@ -38,10 +43,10 @@ public override async Task ExecuteInsertAsync(CancellationToken cancella #endif /// - /// Page queries are not supported by MsAccess database. + /// Page queries are not supported by MS Access database. /// /// This method always throws a . - /// The MsAccess provider does not support paging. + /// The MS Access provider does not support paging. /// public override string BuildPageQuery(long skip, long take, SQLParts parts, ref object[] args) => throw new NotSupportedException("The MS Access provider does not support paging."); diff --git a/PetaPoco/Providers/MariaDbDatabaseProvider.cs b/PetaPoco/Providers/MariaDBDatabaseProvider.cs similarity index 82% rename from PetaPoco/Providers/MariaDbDatabaseProvider.cs rename to PetaPoco/Providers/MariaDBDatabaseProvider.cs index dc50aad5..eb37eaaa 100644 --- a/PetaPoco/Providers/MariaDbDatabaseProvider.cs +++ b/PetaPoco/Providers/MariaDBDatabaseProvider.cs @@ -4,11 +4,13 @@ namespace PetaPoco.Providers { + // TODO: Rename class: MariaDBDatabaseProvider + /// - /// Provides a specific implementation of the class for MariaDB. + /// Provides an implementation of for MariaDB databases. /// /// - /// This class uses the provider. + /// This provider uses the "MySql.Data.MySqlClient" ADO.NET driver for data access. /// public class MariaDbDatabaseProvider : DatabaseProvider { diff --git a/PetaPoco/Providers/MySqlConnectorDatabaseProvider.cs b/PetaPoco/Providers/MySqlConnectorDatabaseProvider.cs index a7bb7d1f..e0ae636e 100644 --- a/PetaPoco/Providers/MySqlConnectorDatabaseProvider.cs +++ b/PetaPoco/Providers/MySqlConnectorDatabaseProvider.cs @@ -5,8 +5,11 @@ namespace PetaPoco.Providers { /// - /// Provides a specific implementation of the class for MySQL using the MySqlConnector library. + /// Provides an implementation of for MySQL databases using the MySqlConnector library. /// + /// + /// This provider uses the "MySqlConnector" ADO.NET driver for data access. + /// public class MySqlConnectorDatabaseProvider : DatabaseProvider { /// diff --git a/PetaPoco/Providers/MySqlDatabaseProvider.cs b/PetaPoco/Providers/MySqlDatabaseProvider.cs index 69a180fe..954defe9 100644 --- a/PetaPoco/Providers/MySqlDatabaseProvider.cs +++ b/PetaPoco/Providers/MySqlDatabaseProvider.cs @@ -5,8 +5,11 @@ namespace PetaPoco.Providers { /// - /// Provides a specific implementation of the class for MySQL. + /// Provides an implementation of for MySQL databases. /// + /// + /// This provider uses the "MySql.Data.MySqlClient" ADO.NET driver for data access. + /// public class MySqlDatabaseProvider : DatabaseProvider { /// diff --git a/PetaPoco/Providers/OracleDatabaseProvider.cs b/PetaPoco/Providers/OracleDatabaseProvider.cs index cfd5dc62..7a06a2b6 100644 --- a/PetaPoco/Providers/OracleDatabaseProvider.cs +++ b/PetaPoco/Providers/OracleDatabaseProvider.cs @@ -12,8 +12,11 @@ namespace PetaPoco.Providers { /// - /// Provides a specific implementation of the class for Oracle. + /// Provides an implementation of for Oracle databases using the managed Oracle Data Provider. /// + /// + /// This provider uses the "Oracle.ManagedDataAccess.Client" ADO.NET driver for data access. + /// public class OracleDatabaseProvider : DatabaseProvider { /// diff --git a/PetaPoco/Providers/PostgreSQLDatabaseProvider.cs b/PetaPoco/Providers/PostgresDatabaseProvider.cs similarity index 89% rename from PetaPoco/Providers/PostgreSQLDatabaseProvider.cs rename to PetaPoco/Providers/PostgresDatabaseProvider.cs index 0531b925..ce3a79c7 100644 --- a/PetaPoco/Providers/PostgreSQLDatabaseProvider.cs +++ b/PetaPoco/Providers/PostgresDatabaseProvider.cs @@ -8,9 +8,14 @@ namespace PetaPoco.Providers { + // TODO: Rename class: PostgresDatabaseProvider + /// - /// Provides a specific implementation of the class for PostgreSQL. + /// Provides an implementation of for PostgreSQL databases. /// + /// + /// This provider uses the "Npgsql" ADO.NET driver for data access. + /// public class PostgreSQLDatabaseProvider : DatabaseProvider { /// diff --git a/PetaPoco/Providers/SQLiteDatabaseProvider.cs b/PetaPoco/Providers/SQLiteDatabaseProvider.cs index b4b3d204..c42d51ff 100644 --- a/PetaPoco/Providers/SQLiteDatabaseProvider.cs +++ b/PetaPoco/Providers/SQLiteDatabaseProvider.cs @@ -7,8 +7,11 @@ namespace PetaPoco.Providers { /// - /// Provides a specific implementation of the class for SQLite. + /// Provides an implementation of for SQLite databases. /// + /// + /// This provider can use either the "System.Data.SQLite" or "Microsoft.Data.Sqlite" ADO.NET drivers for data access. + /// public class SQLiteDatabaseProvider : DatabaseProvider { /// @@ -19,7 +22,7 @@ public override DbProviderFactory GetFactory() public override object MapParameterValue(object value) { if (value is uint u) - return (long) u; + return (long)u; return base.MapParameterValue(value); } diff --git a/PetaPoco/Providers/SqlServerCEDatabaseProviders.cs b/PetaPoco/Providers/SqlServerCeDatabaseProviders.cs similarity index 78% rename from PetaPoco/Providers/SqlServerCEDatabaseProviders.cs rename to PetaPoco/Providers/SqlServerCeDatabaseProviders.cs index 8f320c96..5e6e4c36 100644 --- a/PetaPoco/Providers/SqlServerCEDatabaseProviders.cs +++ b/PetaPoco/Providers/SqlServerCeDatabaseProviders.cs @@ -8,10 +8,15 @@ namespace PetaPoco.Providers { - // TODO: Plural class name? There may be multiple providers this handles, but each instance is still only one. + // TODO: Rename class: SqlServerCeDatabaseProvider + /// - /// Provides a specific implementation of the class for SQL Server CE. + /// Provides an implementation of for Microsoft SQL Server Compact Edition databases. /// + /// + /// This provider uses the "System.Data.SqlServerCe" ADO.NET driver for data access. Note that this driver is end-of-life (reference). + /// public class SqlServerCEDatabaseProviders : DatabaseProvider { /// diff --git a/PetaPoco/Providers/SqlServerDatabaseProvider.cs b/PetaPoco/Providers/SqlServerDatabaseProvider.cs index fb7b0167..cc72d13e 100644 --- a/PetaPoco/Providers/SqlServerDatabaseProvider.cs +++ b/PetaPoco/Providers/SqlServerDatabaseProvider.cs @@ -9,8 +9,14 @@ namespace PetaPoco.Providers { /// - /// Provides a specific implementation of the class for SQL Server. + /// Provides an implementation of for Microsoft SQL Server databases. /// + /// + /// This provider uses the "System.Data.SqlClient" ADO.NET driver for data access. Note that this driver is end-of-life (reference and + /// more info). Consider using as an alternative, which uses the "Microsoft.Data.SqlClient" driver. + /// public class SqlServerDatabaseProvider : DatabaseProvider { /// @@ -20,7 +26,7 @@ public override DbProviderFactory GetFactory() /// public override string BuildPageQuery(long skip, long take, SQLParts parts, ref object[] args) { - var helper = (PagingHelper) PagingUtility; + var helper = (PagingHelper)PagingUtility; // when the query does not contain an "order by", it is very slow if (helper.SimpleRegexOrderBy.IsMatch(parts.SqlSelectRemoved)) { diff --git a/PetaPoco/Providers/SqlServerMsDataDatabaseProvider.cs b/PetaPoco/Providers/SqlServerMSDataDatabaseProvider.cs similarity index 62% rename from PetaPoco/Providers/SqlServerMsDataDatabaseProvider.cs rename to PetaPoco/Providers/SqlServerMSDataDatabaseProvider.cs index c1e3404c..f55b1b62 100644 --- a/PetaPoco/Providers/SqlServerMsDataDatabaseProvider.cs +++ b/PetaPoco/Providers/SqlServerMSDataDatabaseProvider.cs @@ -3,11 +3,13 @@ namespace PetaPoco.Providers { + // TODO: Rename class: SqlServerMSDataDatabaseProvider + /// - /// Provides a specific implementation of the class for Microsoft.Data.SqlClient. + /// Provides an implementation of for Microsoft SQL Server databases. /// /// - /// This class serves as a wrapper for the class. + /// This provider uses the "Microsoft.Data.SqlClient" ADO.NET driver for data access. /// public class SqlServerMsDataDatabaseProvider : SqlServerDatabaseProvider {