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.GlossariesManagerControllerUnitTests;

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

    [Test]
    public async Task Post_WhenCalled_ReturnsOK()
    {
        //Arrange
        var newGlossaryItem = new NewGlossaryItem();

        var cancellationToken = CancellationToken.None;

        //Act
        var actualResult = await _glossariesController.Post(newGlossaryItem, cancellationToken);

        //Assert
        _glossariesManagerMock.Verify(x => x.AddGlossaryItem(It.IsAny<AuditUserDetails>(), newGlossaryItem, cancellationToken), Times.Once);

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