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

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

        [Test]
        public async Task Test_01_PaymentVariant2020() {
            using var ctx = new AppDbContext();
            var v = (await ctx.PaymentVariants.FindAsync(2020, 1))!;
            var data = await PaymentVariantSummaryData.ForPaymentVariant(v, ctx.PaymentVariantSummaryRows);
            using var doc = new PaymentVariantSummary(v, data);
            var text = await Utils.GeneratePdfText(doc, true);
            var table = Utils.ExtractTable(text);
            Assert.Multiple(() => {
                Assert.That(text, Contains.Substring("Auszahlungsvariante"));
                Assert.That(text, Contains.Substring(v.Name));
                Assert.That(table.Skip(17).ToArray(), Is.EqualTo(new string[][] {
                     [                   "Gradation",   "ungebunden",   "attributlos gebunden",    "gebunden",     "Gesamt" ],
                     [                     "[°Oe]",   "[kg]", "[€/kg]",    "[kg]", "[€/kg]",    "[kg]", "[€/kg]",    "[€]"  ],
                     ["Grüner Veltliner",            "3 219",                 "0",                 "0",           "1 609,50"],
                     ["Qualitätswein",      "73",    "3 219", "0,5000",       "-",      "-",       "-",      "-", "1 609,50"]
                }));
            });
        }
    }
}
