Skip to content

Commit

Permalink
Changed integration tests to not use master db
Browse files Browse the repository at this point in the history
  • Loading branch information
codemunkie15 committed Oct 25, 2024
1 parent ef04ca9 commit 1d4b74d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using EFCore.ChangeTriggers.Metadata;
using Microsoft.EntityFrameworkCore.Diagnostics;
using System.Data.Common;
using System.Diagnostics;

namespace EFCore.ChangeTriggers.Interceptors
{
Expand All @@ -22,8 +21,6 @@ public BaseChangedByDbConnectionInterceptor(

public override void ConnectionOpened(DbConnection connection, ConnectionEndEventData eventData)
{
Debugger.Launch();

if (eventData.Context == null)
{
// TODO: what exception?
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Testcontainers.MsSql;

Expand All @@ -11,7 +12,7 @@ public abstract class ContainerFixture<TDbContext> : IAsyncLifetime

public abstract bool MigrateDatabase { get; }

protected MsSqlContainer msSqlContainer;
private MsSqlContainer msSqlContainer;

public virtual async Task InitializeAsync()
{
Expand All @@ -21,7 +22,7 @@ public virtual async Task InitializeAsync()

await msSqlContainer.StartAsync();

Services = BuildServiceProvider(msSqlContainer.GetConnectionString());
Services = BuildServiceProvider(GetChangeTriggersConnectionString());

if (MigrateDatabase)
{
Expand All @@ -38,8 +39,16 @@ public virtual async Task DisposeAsync()

protected abstract IServiceProvider BuildServiceProvider(string connectionString);

protected virtual void SetMigrationChangeContext()
protected virtual void SetMigrationChangeContext() { }

private string GetChangeTriggersConnectionString()
{
var builder = new SqlConnectionStringBuilder(msSqlContainer.GetConnectionString())
{
InitialCatalog = "ChangeTriggers"
};

return builder.ToString();
}
}
}

0 comments on commit 1d4b74d

Please sign in to comment.