using e_suite.API.Common.models;
using e_suite.Database.Audit;
using Microsoft.AspNetCore.Mvc;
using Moq;
using NUnit.Framework;

namespace eSuite.API.UnitTests.Controllers.SsoManagerControllerUnitTests;

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

    [Test]
    public async Task AddProvider_WhenCalled_ReturnsOk()
    {
        //Arrange
        var cancellationToken = CancellationToken.None;

        var ssoProvider = new CreateSsoProvider();

        //Act
        var actualResult = await SsoManagerController.AddProvider(ssoProvider, cancellationToken);

        //Assert
        SsoManagerMock.Verify(x => x.AddSsoProviderAsync(It.IsAny<AuditUserDetails>(), ssoProvider, cancellationToken), Times.Once);
        Assert.That(actualResult.GetType(), Is.EqualTo(typeof(OkResult)));
    }
}