using Microsoft.Extensions.Configuration;
using e_suite.API.Common.repository;
using e_suite.Service.Mail.Facade;
using e_suite.UnitTestCore;
using eSuite.Core.MailService;
using Moq;

namespace e_suite.Service.Mail.UnitTests;

public class MailServiceTestBase : TestBase
{
    protected IConfiguration configuration = null!;
    protected IMailService mailService = null!;
    protected Mock<IUserManagerRepository> UserManagerRepositoryMock = null!;
    protected Mock<IMailServiceRepository> MailServiceRepositoryMock = null!;
    protected Mock<ISmtpClientFactory> MailClientFactoryMock = null!;

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

        var imMemorySettings = new Dictionary<string, string>
        {
            { "Smtp:Username", "TestUsername" },
            { "Smtp:Password", "It is a secret" },
            { "Smtp:FromAddress", "testSender@test.com"}
        };

        configuration = new ConfigurationBuilder()
            .AddInMemoryCollection(imMemorySettings!)
            .Build();

        UserManagerRepositoryMock = new Mock<IUserManagerRepository>();
        MailServiceRepositoryMock = new Mock<IMailServiceRepository>();
        MailClientFactoryMock = new Mock<ISmtpClientFactory>();

        mailService = new Mail.MailService(configuration, UserManagerRepositoryMock.Object,
            MailServiceRepositoryMock.Object, MailClientFactoryMock.Object);
    }
}