Skip to content

Commit 1075a46

Browse files
authored
fix: support non-relational db (#49)
Fix #47
1 parent aabc099 commit 1075a46

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

src/ArwynFr.IntegrationTesting/DatabaseTestStrategy.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public DatabaseTestStrategy<TContext> WithTransaction()
4242
}
4343

4444
private static Task UpdateDatabase(TContext context)
45-
=> context.Database.GetMigrations().Any()
45+
=> context.Database.IsRelational()
46+
&& context.Database.GetMigrations().Any()
4647
? context.Database.MigrateAsync()
4748
: context.Database.EnsureCreatedAsync();
4849
}

test/ArwynFr.IntegrationTesting.Tests/ArwynFr.IntegrationTesting.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<PrivateAssets>all</PrivateAssets>
1212
</PackageReference>
1313
<PackageReference Include="FluentAssertions" Version="6.12.0" />
14+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.6" />
1415
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
1516
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.1">
1617
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
using ArwynFr.IntegrationTesting.Tests.Target;
2+
using FluentAssertions;
3+
using Microsoft.EntityFrameworkCore;
4+
using Xunit;
5+
using Xunit.Abstractions;
6+
7+
namespace ArwynFr.IntegrationTesting.Tests.EntityFrameworkCore;
8+
9+
public class DatabaseNonRelationalTests(ITestOutputHelper output) : IntegrationTestBase<Program, MigrationDbContext>(output)
10+
{
11+
[Fact]
12+
public void TestShouldCreateDatabase()
13+
{
14+
Database.Database.IsInMemory().Should().BeTrue();
15+
}
16+
17+
protected override IDatabaseTestStrategy<MigrationDbContext> DatabaseTestStrategy
18+
=> IDatabaseTestStrategy<MigrationDbContext>.DatabasePerTest;
19+
20+
protected override void ConfigureDbContext(DbContextOptionsBuilder builder)
21+
=> builder.UseInMemoryDatabase(Guid.NewGuid().ToString());
22+
}

0 commit comments

Comments
 (0)