using e_suite.Database.Audit;
using eSuite.Core.Miscellaneous;
using Microsoft.AspNetCore.Mvc;
using Moq;
using NUnit.Framework;

namespace eSuite.API.UnitTests.Controllers.UserManagerControllerUnitTests;

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

    [Test]
    public void ResendConfirmEmail_UserIsNull_ThrowsArgumentNullException()
    {
        //Arrange
        GeneralIdRef userId = null!;

        //Assert
        Assert.ThrowsAsync<ArgumentNullException>(async () =>
        {
            //Act
            var actualResult = await _userManagerController.ResendConfirmEmail(userId, CancellationToken.None);
        });
    }

    [Test]
    public async Task ResendConfirmEmail_UserSupplied_CallerUserManager()
    {
        //Arrange
        var userId = new GeneralIdRef
        {
            Guid = new Guid("5cb7c467-5454-416d-91db-1cb795c0d3e4")
        };

        //Act
        var actualResult = await _userManagerController.ResendConfirmEmail(userId, CancellationToken.None);

        //Assert
        _userManagerMock.Verify(x => x.ResendConfirmEmail(It.IsAny<AuditUserDetails>(), userId, It.IsAny<CancellationToken>()), Times.Once);

        Assert.That(actualResult.GetType(), Is.EqualTo(typeof(OkResult)));
    }
}