using e_suite.Messaging.Common;
using e_suite.Scheduler.Jobs;
using e_suite.UnitTestCore;
using Microsoft.Extensions.Logging;
using Moq;
using NUnit.Framework;

namespace e_suite.MessageProcessor.UnitTests;

[TestFixture]
public class NightlyCleanUpUnitTests : TestBase
{
    protected Mock<IDatabaseMessageSender> DatabaseMessageSenderMock { get; set; } = null!;
    protected Mock<ILogger> LoggerMock { get; set; } = null!;
    protected NightlyCleanUp NightlyCleanUp { get; set; } = null!;

    [SetUp]
    public override Task Setup()
    {
        DatabaseMessageSenderMock = new Mock<IDatabaseMessageSender>();
        LoggerMock = new Mock<ILogger>();

        NightlyCleanUp = new NightlyCleanUp(DatabaseMessageSenderMock.Object, LoggerMock.Object);

        return base.Setup();
    }

    [Test]
    public async Task NightlyCleanUp_WhenCalled_InvokesExpectedMaintenanceMethods()
    {
        //Arrange
       
        //Act
        await NightlyCleanUp.ExecuteAsync();

        //Assert
        DatabaseMessageSenderMock.Verify( x => x.PostClearOldEmailActions(), Times.Once);
        DatabaseMessageSenderMock.Verify(x => x.PostClearOldPerformanceData(), Times.Once);
        DatabaseMessageSenderMock.Verify(x => x.PostClearOldSentinelData(), Times.Once);
    }

}