using e_suite.Database.Core.Tables.Forms;

namespace e_suite.Modules.CustomFieldManagerUnitTests.CustomFieldHelperUnitTests;

[TestFixture]
public class GetFormTemplateByGeneralRefIdAsyncUnitTests : CustomFieldsTestBase<object>
{
    [SetUp]
    public override async Task Setup() => await base.Setup();

    [Test]
    public async Task GetFormTemplateByGeneralRefIdAsync_WhenGeneralRefIdDoesNotExist_ReturnsNull()
    {
        //Arrange
        var idRef = new GeneralIdRef();

        //Act
        var result = await _customFieldHelper.GetFormTemplateByGeneralRefIdAsync(idRef, CancellationToken.None);

        //Assert
        Assert.That(result, Is.Null);
    }


    [Test]
    public async Task GetFormTemplateByGeneralRefIdAsync_WhenGeneralRefIdExists_ReturnsExpectedValue()
    {
        //Arrange
        var idRef = new GeneralIdRef
        {
            Id = 72
        };

        _fakeCustomFieldReferenceRepository.FormTemplates.Add( new FormTemplate()
        {
            Id = 72
        });

        //Act
        var result = await _customFieldHelper.GetFormTemplateByGeneralRefIdAsync(idRef, CancellationToken.None);

        //Assert
        Assert.That(result, Is.Not.Null);
        Assert.That(result!.Id, Is.EqualTo(72));
    }
}