using e_suite.Database.Core.Tables.Sequences;
using e_suite.Utilities.Pagination;
using eSuite.Core.Sequences;
using NUnit.Framework;
using SequenceManager.UnitTests.Helpers;

namespace SequenceManager.UnitTests;

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

    [Test]
    public async Task GetSequences_Called_ReturnsSequenceList()
    {
        // Arrange
        SequenceManagerRepository.Sequences.Add(new Sequence
        {
            Id = 1,
            Guid = Guid.NewGuid(),
            Increment = 1,
            Name = "Sequence name",
            Pattern = "Order [0000] from {DD}-{MM}-{YYYY}",
            Rollover = Rollover.Day,
            Deleted = false,
            Seed = 1
        });

        SequenceManagerRepository.Sequences.Add(new Sequence
        {
            Id = 2,
            Guid = Guid.NewGuid(),
            Increment = 1,
            Name = "Another sequence name",
            Pattern = "Order [0000] from {DD}-{MM}-{YYYY}",
            Rollover = Rollover.Day,
            Deleted = false,
            Seed = 1
        });

        var paging = new Paging();

        // Act
        var sequences = await SequenceManager.GetSequences(paging, default);

        // Assert
        Assert.That(sequences, Is.Not.Null);
        Assert.That(sequences.Count, Is.EqualTo(2));
        Assert.That(sequences.Data, Is.Not.Null);
        Assert.That(sequences.Data.Count(), Is.EqualTo(2));
    }
}