using e_suite.API.Common.models;
using eSuite.Core.MailService;
using eSuite.Core.Miscellaneous;
using Microsoft.AspNetCore.Mvc;
using Moq;
using NUnit.Framework;

namespace eSuite.API.UnitTests.Controllers.MailTemplatesControllerUnitTests;

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

    [Test]
    public async Task GetMailTemplateTypes_WhenCalled_ReturnsPagedData()
    {
        //Arrange
        var generalIdRef = new GeneralIdRef();

        var mailType = MailType.PasswordReset;

        var cancellationToken = CancellationToken.None;

        var mailTemplate = new GetMailTemplate();

        _mailTemplateManagerMock.Setup(x => x.GetMailTemplate(generalIdRef, mailType, cancellationToken))
            .ReturnsAsync(mailTemplate);

        //Act
        var actualResult = await _mailTemplatesController.GetMailTemplate(generalIdRef, mailType, cancellationToken);

        //Assert
        Assert.That(actualResult.GetType(), Is.EqualTo(typeof(OkObjectResult)));
        var objectResult = actualResult as OkObjectResult;

        Assert.That(objectResult?.StatusCode, Is.EqualTo(200));
        Assert.That(objectResult!.Value, Is.EqualTo(mailTemplate));
    }
}