Add EF Core package references and DbRepositoryTests
Updated `DigitalData.Core.Tests.csproj` to include conditional package references for Entity Framework Core and its InMemory provider for net7.0, net8.0, and net9.0. Added `DbRepositoryTests` class with setup and teardown methods for managing the lifecycle of a host instance.
This commit is contained in:
@@ -29,4 +29,19 @@
|
||||
<ProjectReference Include="..\DigitalData.Core.Security\DigitalData.Core.Security.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.20" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.20" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.15" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.15" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="9.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
23
DigitalData.Core.Tests/Infrastructure/DbRepositoryTests.cs
Normal file
23
DigitalData.Core.Tests/Infrastructure/DbRepositoryTests.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
namespace DigitalData.Core.Tests.Infrastructure;
|
||||
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
public class DbRepositoryTests
|
||||
{
|
||||
private IHost _host;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
var builder = Host.CreateApplicationBuilder();
|
||||
|
||||
_host = builder.Build();
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
if (_host is IDisposable disposableHost)
|
||||
disposableHost.Dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user