Refactor repeated test host setup

This commit is contained in:
2026-04-01 10:48:28 +02:00
parent 18d1de45cb
commit 517c42250d
10 changed files with 74 additions and 140 deletions
@@ -1,13 +1,13 @@
using JobTrackerApi.Controllers;
using JobTrackerApi.Models;
using JobTrackerApi.Services;
using JobTrackerApi.Tests.TestSupport;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore.Query;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using Moq;
using System.Collections;
using System.Linq.Expressions;
@@ -162,18 +162,7 @@ public sealed class AuthAndSystemControllerTests
private static Mock<UserManager<ApplicationUser>> CreateUserManager()
{
var store = new Mock<IUserStore<ApplicationUser>>();
return new Mock<UserManager<ApplicationUser>>(
store.Object,
Options.Create(new IdentityOptions()),
new PasswordHasher<ApplicationUser>(),
Array.Empty<IUserValidator<ApplicationUser>>(),
Array.Empty<IPasswordValidator<ApplicationUser>>(),
new UpperInvariantLookupNormalizer(),
new IdentityErrorDescriber(),
null!,
new NullLogger<UserManager<ApplicationUser>>()
);
return TestHostFactory.CreateUserManager();
}
private sealed class TestAsyncQueryProvider<TEntity> : IAsyncQueryProvider