using EDPlayerJournal;
using EDPlayerJournal.BGS;
using EDPlayerJournal.Entries;

namespace EDPlayerJournalTests;

[TestClass]
public class ThargoidKills {
    [TestMethod]
    public void ThargoidBonks() {
        TransactionParser parser = new();

        List<Entry>? entries = Helper.LoadTestData("ThargoidKills.txt");
        Assert.IsNotNull(entries, "could not load test data");

        if (entries == null) {
            return;
        }

        List<ThargoidKill>? transactions = parser.Parse(entries)?.OfType<ThargoidKill>().ToList();

        Assert.IsNotNull(transactions, "could not parse entries");
        Assert.AreEqual(transactions.Count, 3);

        // In recent updates the payout was changed, that's why this test reports unknown thargoid vessels
        // This test makes sure the new parser does not conflict with legacy values
        //
        Assert.IsInstanceOfType(transactions[0], typeof(ThargoidKill), "result is not of type ThargoidKill");
        Assert.AreEqual(transactions[0].ThargoidType, EDPlayerJournal.ThargoidVessel.Unknown);

        Assert.IsInstanceOfType(transactions[1], typeof(ThargoidKill), "result is not of type ThargoidKill");
        Assert.AreEqual(transactions[1].ThargoidType, EDPlayerJournal.ThargoidVessel.Unknown);

        Assert.IsInstanceOfType(transactions[2], typeof(ThargoidKill), "result is not of type ThargoidKill");
        Assert.AreEqual(transactions[2].ThargoidType, EDPlayerJournal.ThargoidVessel.Unknown);
    }

    [TestMethod]
    public void ThargoidBonds() {
        TransactionParser parser = new();

        List<Entry>? entries = Helper.LoadTestData("ThargoidBonds.txt");
        Assert.IsNotNull(entries, "could not load test data");

        if (entries == null) {
            return;
        }

        List<Vouchers>? transactions = parser.Parse(entries)?.OfType<Vouchers>().ToList();

        Assert.IsNotNull(transactions, "could not parse entries");
        Assert.AreEqual(transactions.Count, 1);
        Assert.AreEqual(Factions.IsPilotsFederation(transactions[0].Faction), true);
        Assert.AreEqual(transactions[0].TotalSum, 24240000L);
        Assert.AreEqual(transactions[0].Type, "Combat Bond");
    }
}
