using JobTrackerApi.Models; using Microsoft.AspNetCore.Identity; using Microsoft.Extensions.Logging.Abstractions; using Microsoft.Extensions.Options; using Moq; namespace JobTrackerApi.MariaDb.Tests; internal static class TestHostFactory { public static Mock> CreateUserManager(ApplicationUser? lookupUser = null) { var manager = new Mock>( Mock.Of>(), Options.Create(new IdentityOptions()), new PasswordHasher(), Array.Empty>(), Array.Empty>(), new UpperInvariantLookupNormalizer(), new IdentityErrorDescriber(), null!, NullLogger>.Instance); if (lookupUser is not null) manager.Setup(x => x.FindByIdAsync(It.IsAny())) .ReturnsAsync((string id) => lookupUser.Id == id ? lookupUser : null); return manager; } }