using e_suite.Database.Core.Tables.Glossaries;

namespace e_suite.Modules.CustomFieldManagerUnitTests.CustomFieldHelperUnitTests;

[TestFixture]
public class GetGlossaryByGeneralRefIdAsyncUnitTests : 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.GetGlossaryByGeneralRefIdAsync(idRef, CancellationToken.None);

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


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

        _fakeCustomFieldReferenceRepository.Glossaries.Add(new Glossary()
        {
            Id = 83
        });

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

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