using e_suite.Messaging.Common.models;
using e_suite.Messaging.Common.UnitTests.Helpers;
using NUnit.Framework;

namespace e_suite.Messaging.Common.UnitTests;

[TestFixture]
public class DatabaseMessageSenderUnitTests : DatabaseMessageSenderTestBase
{
    [SetUp]
    public override async Task Setup()
    {
        await base.Setup();
    }

    [TearDown]
    public override async Task TearDown()
    {
        await base.TearDown();
    }

    [Test]
    public void NewDatabaseMessageSender_WhenCreated_DoesNotThrowException()
    {
        Assert.That(DatabaseMessageSender, Is.Not.Null);
    }

    private const string BasicMessage = "{{\"MessageType\":{0}}}";

    [Test]
    public void PostClearOldSentinelData_WhenCalled_SendsCorrectMessage()
    {
        //Arrange
        // Act
        DatabaseMessageSender.PostClearOldSentinelData();

        // Assert
        Assert.That(Body, Is.EqualTo(string.Format(BasicMessage, (int)DatabaseMessageTypes.ClearOldSentinelData)));
    }

    [Test]
    public void PostClearOldPerformanceData_WhenCalled_SendsCorrectMessage()
    {
        //Arrange
        //Act
        DatabaseMessageSender.PostClearOldPerformanceData();

        //Assert
        Assert.That(Body, Is.EqualTo(string.Format(BasicMessage, (int)DatabaseMessageTypes.ClearOldPerformanceData)));
    }

    [Test]
    public void PostClearOldEmailActions_WhenCalled_SendsCorrectMessage()
    {
        //Arrange
        //Act
        DatabaseMessageSender.PostClearOldEmailActions();

        //Assert
        Assert.That(Body, Is.EqualTo(string.Format(BasicMessage, (int)DatabaseMessageTypes.ClearOldEmailActions)));
    }

    [Test]
    public void PostClearOldSingleUserGuids_WhenCalled_SendsCorrectMessage()
    {
        //Arrange
        //Act
        DatabaseMessageSender.PostClearOldSingleUserGuids();

        //Assert
        Assert.That(Body, Is.EqualTo(string.Format(BasicMessage, (int)DatabaseMessageTypes.ClearOldSingleUserGuids)));
    }
}