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

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

        [Test]
        public async Task Test_01_AllAnnouncements2020() {
            using var ctx = new AppDbContext();
            var filter = "01.10.2020 – Matzen – GV Kabinettaktion";
            var data = await DeliveryAncmtListData.FromQuery(ctx.DeliveryAnnouncements.Where(a => a.Year == 2020 && a.DsNr == 1), [filter]);
            using var doc = new DeliveryAncmtList(filter, data);
            var text = await Utils.GeneratePdfText(doc, true);
            var table = Utils.ExtractTable(text);
            Assert.Multiple(() => {
                Assert.That(text, Contains.Substring("Anmeldeliste"));
                Assert.That(text, Contains.Substring("01.10.2020 – Matzen – GV Kabinettaktion"));
                Assert.That(table, Is.EqualTo(new string[][] {
                    ["01.10.2020", "101 MUSTERMANN Max",       "Hohenruppersdorf", "Grüner Veltliner", "-",  "5 000"],
                    ["01.10.2020", "102 WEINBAUER Wernhardt",  "Hohenruppersdorf", "Grüner Veltliner", "-", "10 000"],
                    ["01.10.2020", "103 MUSTERBAUER Matthäus", "Wolkersdorf",      "Grüner Veltliner", "-",  "8 000"],
                    ["01.10.2020", "104 WINZER Waltraud",      "Wolkersdorf",      "Grüner Veltliner", "-",  "2 000"],
                    ["Gesamt:",        "Anmeldungen: 4",                                                    "25 000"],
                }));
            });
        }
    }
}
