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

namespace eSuite.API.UnitTests.Controllers.FormsControllerUnitTests;

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

    [Test]
    public async Task CreateFormInstance_NormanConditions_Returns200OkObjResult()
    {
        //Arrange
        var generalIdRef = new GeneralIdRef
        {
            Guid = new Guid("320951a7-ba70-419f-8263-411aec720d59"),
            Id = 5,
        };

        var formInstance = new EditFormInstance();

        var cancellationToken = CancellationToken.None;

        var newGeneralIdRef = new GeneralIdRef
        {
            Guid = new Guid("e8a8ca81-e7f6-4dc8-9610-d31a4345e331"),
            Id = 2354,
        };

        //Act
        var res = await _formsController.EditFormInstance(formInstance, cancellationToken);

        //Assert
        _formsManagerMock!.Verify(x => x.EditFormInstanceAsync(It.IsAny<AuditUserDetails>(), formInstance, cancellationToken), Times.Once);

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