using Elwig.Documents;
using Elwig.Helpers;
using Elwig.Models.Dtos;

namespace Tests.UnitTests.DocumentTests {
    [TestFixture]
    public class MemberListTest {

        [Test]
        public async Task Test_01_TwoMembers() {
            using var ctx = new AppDbContext();
            var data = await MemberListData.FromQuery(ctx.Members, [], []);
            using var doc = new MemberList("Alle Mitglieder", data);
            var text = await Utils.GeneratePdfText(doc, true);
            var table = Utils.ExtractTable(text);
            Assert.Multiple(() => {
                Assert.That(text, Contains.Substring("Mitgliederliste"));
                Assert.That(text, Contains.Substring("Alle Mitglieder"));
                Assert.That(table.Take(3), Is.EqualTo(new string[][] {
                     ["101 MUSTERMANN Max",      "Winzerstraße 1", "2223", "Hohenruppersdorf", "0123463", "0", "Hohenruppersdorf"],
                     ["102 WEINBAUER Wernhardt", "Winzerstraße 2", "2223", "Hohenruppersdorf", "0123471", "0", "Hohenruppersdorf"],
                     [    "W&B Weinbauer GesbR", "Winzerstraße 2", "2223", "Hohenruppersdorf"],
                }));
            });
        }
    }
}
