using e_suite.API.Common;
using e_suite.Database.Audit;
using e_suite.UnitTestCore;
using Moq;

namespace SSOManager.UnitTests.Helpers;

public class SsoManagerTestBase<T> : TestBase
{
    protected FakeSsoManagerRepository SsoManagerRepository = null!;

    public Mock<IPatchFactory> PatchFactoryMock = null!;
    public Mock<IPatch<T>> PatchMock { get; set; }

    protected AuditUserDetails AuditUserDetails = null!;

    protected ISsoManager SsoManager = null!;

    public override async Task Setup()
    {
        await base.Setup();

        AuditUserDetails = new AuditUserDetails
        {
            UserId = -1,
            UserDisplayName = "Testing User",
            Comment = "Test comment"
        };

        PatchFactoryMock = new Mock<IPatchFactory>();
        PatchMock = new Mock<IPatch<T>>();
        PatchFactoryMock
            .Setup(f => f.Create(It.IsAny<T>()))
            .Returns(PatchMock.Object);

        SsoManagerRepository = new FakeSsoManagerRepository();

        SsoManager = new e_suite.Modules.SSOManager.SsoManager(SsoManagerRepository, PatchFactoryMock.Object);
    }
}