Skip to content

Commit

Permalink
Merge pull request #701 from Ste1io/Ste1io/separate-dbms-driver-tests
Browse files Browse the repository at this point in the history
Integration tests refactor to separate DBMS/driver tests
  • Loading branch information
pleb authored Oct 11, 2023
2 parents 9d4ad94 + 4d1184a commit 53e928c
Show file tree
Hide file tree
Showing 238 changed files with 2,265 additions and 1,962 deletions.
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"ms-dotnettools.csdevkit",
"ms-azuretools.vscode-docker"
]
}
Binary file not shown.
Binary file not shown.
30 changes: 0 additions & 30 deletions PetaPoco.Tests.Integration/Databases/BaseDatabase.cs

This file was deleted.

27 changes: 27 additions & 0 deletions PetaPoco.Tests.Integration/Databases/BaseDbContext.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
14 changes: 0 additions & 14 deletions PetaPoco.Tests.Integration/Databases/BaseTriageTests.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,7 +23,7 @@ public abstract class BaseDatabaseTests : BaseDatabase

#endregion

protected BaseDatabaseTests(DBTestProvider provider)
protected DatabaseTests(TestProvider provider)
: base(provider)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -49,7 +49,7 @@ public abstract class BaseDeleteTests : BaseDatabase

#endregion

protected BaseDeleteTests(DBTestProvider provider)
protected DeleteTests(TestProvider provider)
: base(provider)
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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())
{
}
}
}
Original file line number Diff line number Diff line change
@@ -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())
{
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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())
{
}
}
}
Original file line number Diff line number Diff line change
@@ -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())
{
}
}
}
Original file line number Diff line number Diff line change
@@ -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())
{
}
}
}
Original file line number Diff line number Diff line change
@@ -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<PreExecuteDatabaseProvider>().Create();
}

protected class PreExecuteDatabaseProvider : PetaPoco.Providers.FirebirdDbDatabaseProvider, IPreExecuteDatabaseProvider
{
public bool ThrowExceptions { get; set; }
public List<IDataParameter> Parameters { get; set; } = new List<IDataParameter>();

public override void PreExecute(IDbCommand cmd)
{
Parameters.Clear();

if (ThrowExceptions)
{
Parameters = cmd.Parameters.Cast<IDataParameter>().ToList();
throw new PreExecuteException();
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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())
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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())
{
}
}
}
}
Loading

0 comments on commit 53e928c

Please sign in to comment.