using e_suite.API.Common;
using e_suite.Database.Audit;
using e_suite.Service.SigmaImporter.GmgProfiles;
using e_suite.Service.SigmaImporter.Helpers;
using e_suite.Service.SigmaImporter.Repository;
using e_suite.UnitTestCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Moq;

namespace SigmaImporter.UnitTests.Helpers;

public class GmgProfileImporterTestBaseWithMySql : TestBase
{
    protected Mock<ISigmaFileBrowserRepository> SigmaFileBrowserRepositoryMock { get; set; } = null!;
    protected Mock<IGlossariesManager> GlossariesManagerMock { get; set; } = null!;
    protected Mock<ILogger> LoggerMock { get; set; } = null!;

    protected Guid GmgProfileGuid { get; } = new("BBA078CF-8326-40B8-92EC-ECD9A2017702");

    protected ImportGlossaryHelper ImportGlossaryHelper { get; set; } = null!;

    protected AuditUserDetails AuditUserDetails = new()
    {
        Comment = "SigmaImporter Automated import",
        UserDisplayName = "MessageProcessor"
    };

    public IGmgProfileImporter GmgProfileImporter { get; set; } = null!;

    public override async Task Setup()
    {
        await base.Setup();
        SigmaFileBrowserRepositoryMock = new Mock<ISigmaFileBrowserRepository>();
        GlossariesManagerMock = new Mock<IGlossariesManager>();
        LoggerMock = new Mock<ILogger>();

        var appSettingsStub = new Dictionary<string, string> {
            //{"applicationName", "e-suite test"},
            //{"baseUrl", "https://esuite.test"},
            //{"Smtp:EmailTimeoutHours", "48"},
            //{"Smtp:Server", "127.0.0.1"},
            //{"Smtp:Port", "25"},
            //{"Smtp:FromAddress", "esuitetest@sun-strategy.com"},
            //{"JwtConfig:secret", "Z8p9YKvYnwm62sPLJVdvp3M7bQ5l0UqRGwz95ZqL"},
            //{"JwtConfig:expirationInMinutes", "15"},
            //{"JwtConfig:audience", "test"},
            //{"JwtConfig:issuer", "moq"},
            //{"Sentinel:LoginAttemptTimeoutMinutes", "60"},
            //{"Sentinel:MaxLoginAttempts", "5"}
            //{"Sentinel:MaxLoginAttempts", "5"}
            {"SigmaFileBrowser:Server","localhost"}
        };

        _configuration = new ConfigurationBuilder()
            .AddInMemoryCollection(appSettingsStub!)
            .Build();

        ImportGlossaryHelper = new ImportGlossaryHelper(GlossariesManagerMock.Object);

        GmgProfileImporter = new e_suite.Service.SigmaImporter.GmgProfiles.GmgProfileImporter(SigmaFileBrowserRepositoryMock.Object, GlossariesManagerMock.Object, _configuration, LoggerMock.Object, ImportGlossaryHelper);
    }
}