using e_suite.Database.Audit;
using eSuite.API.Models;
using Microsoft.AspNetCore.Mvc;
using Moq;
using NUnit.Framework;

namespace eSuite.API.UnitTests.Controllers.BlockedIPsControllerUnitTests;

[TestFixture]
public class UnblockIPAddressUnitTests: BlockedIPsControllerTestBase
{
    [SetUp]
    public override async Task Setup() => await base.Setup();

    [Test]
    public async Task UnblockIPAddress_NormanConditions_Returns200OkObjResult()
    {
        //Arrange
        var blockedIPAddress = new BlockedIPAddress
        {
            IpAddress = "127.0.0.1"
        };
        var cancellationToken = CancellationToken.None;

        _blockedIPsManagerMock?.Setup(x => x.UnblockIPAddress(It.IsAny<AuditUserDetails>(), blockedIPAddress.IpAddress, It.IsAny<CancellationToken>())).Returns(Task.CompletedTask);

        //Act
        var res = await _blockedIPsController.Delete(blockedIPAddress, cancellationToken);

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