refactor(DbRepositoryTests): Update AddDbRepository configuration

This commit is contained in:
Developer 02 2025-04-22 16:32:17 +02:00
parent 3955dede16
commit f1f5b9e16d
4 changed files with 5 additions and 2 deletions

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net9.0</TargetFramework> <TargetFrameworks>net7.0;net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>

View File

@ -9,6 +9,7 @@ public class DbRepository<TDbContext, TEntity> : IRepository<TEntity> where TDbC
protected internal readonly TDbContext Context; protected internal readonly TDbContext Context;
protected internal readonly DbSet<TEntity> Entities; protected internal readonly DbSet<TEntity> Entities;
public IEntityMapper<TEntity> Mapper { get; } public IEntityMapper<TEntity> Mapper { get; }
public DbRepository(TDbContext context, Func<TDbContext, DbSet<TEntity>> queryFactory, IEntityMapper<TEntity> mapper) public DbRepository(TDbContext context, Func<TDbContext, DbSet<TEntity>> queryFactory, IEntityMapper<TEntity> mapper)

View File

@ -26,6 +26,7 @@
<ProjectReference Include="..\DigitalData.Core.Application\DigitalData.Core.Application.csproj" /> <ProjectReference Include="..\DigitalData.Core.Application\DigitalData.Core.Application.csproj" />
<ProjectReference Include="..\DigitalData.Core.Client\DigitalData.Core.Client.csproj" /> <ProjectReference Include="..\DigitalData.Core.Client\DigitalData.Core.Client.csproj" />
<ProjectReference Include="..\DigitalData.Core.DTO\DigitalData.Core.DTO.csproj" /> <ProjectReference Include="..\DigitalData.Core.DTO\DigitalData.Core.DTO.csproj" />
<ProjectReference Include="..\DigitalData.Core.Infrastructure.AutoMapper\DigitalData.Core.Infrastructure.AutoMapper.csproj" />
<ProjectReference Include="..\DigitalData.Core.Infrastructure\DigitalData.Core.Infrastructure.csproj" /> <ProjectReference Include="..\DigitalData.Core.Infrastructure\DigitalData.Core.Infrastructure.csproj" />
<ProjectReference Include="..\DigitalData.Core.Security\DigitalData.Core.Security.csproj" /> <ProjectReference Include="..\DigitalData.Core.Security\DigitalData.Core.Security.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -7,6 +7,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using System.Reflection; using System.Reflection;
using DigitalData.Core.Abstractions.Infrastructure; using DigitalData.Core.Abstractions.Infrastructure;
using DigitalData.Core.Infrastructure.AutoMapper;
public class DbRepositoryTests public class DbRepositoryTests
{ {
@ -21,7 +22,7 @@ public class DbRepositoryTests
builder.Services.AddDbContext<MockDbContext>(opt => opt.UseInMemoryDatabase("MockDB")); builder.Services.AddDbContext<MockDbContext>(opt => opt.UseInMemoryDatabase("MockDB"));
builder.Services.AddDbRepository<MockDbContext, User>(context => context.Users); builder.Services.AddDbRepository<MockDbContext, User>(context => context.Users).UseAutoMapper(typeof(UserCreateDto), typeof(UserReadDto));
builder.Services.AddAutoMapper(Assembly.GetExecutingAssembly()); builder.Services.AddAutoMapper(Assembly.GetExecutingAssembly());