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 PutUnitTests : GlossariesManagerControllerTestBase
{
    [SetUp]
    public override async Task Setup()
    {
        await base.Setup();
    }

    [Test]
    public async Task Put_WhenCalled_ReturnsOK()
    {
        //Arrange
        var glossaryItem = new EditGlossaryItem();

        var cancellationToken = CancellationToken.None;

        //Act
        var actualResult = await _glossariesController.Put(glossaryItem, cancellationToken);

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

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