using Microsoft.Playwright.NUnit;
using NUnit.Framework;

namespace Tests.Specs;

[Parallelizable(ParallelScope.Self)]
[FixtureLifeCycle(LifeCycle.SingleInstance)]
public class HarassCalculatorTests : PageTest
{
    private Website _website = null!;

    [SetUp]
    public void CreateWebsite()
    {
        _website = new Website(Page);
    }

    [Test]
    public async Task CalculatorInput()
    {
        var page = _website.HarassCalculatorPage;
        await page.GotoAsync();
        await page.SetWorkersLostToHarassAsync(3);
        await page.SetNumberOfTownHallsExistingAsync(2);
        await page.SetTownHallTravelTimeAsync(0, 30);
        var result = await page.GetTotalAlloyHarassmentAsync();
        Assert.That(result, Is.EqualTo(240));
    }

    [Test]
    public async Task CalculatedExampleInformation()
    {
        var page = _website.HarassCalculatorPage;
        await page.GotoAsync();

        Assert.Multiple(async () =>
        {
            Assert.That(await page.GetExampleTotalAlloyLossAsync(), Is.EqualTo(720));
            Assert.That(await page.GetExampleWorkerCostAsync(), Is.EqualTo(300));
            Assert.That(await page.GetExampleMiningTimeCostAsync(), Is.EqualTo(420));
            Assert.That(await page.GetExampleTotalAlloyLossAccurateAsync(), Is.EqualTo(450));
            Assert.That(await page.GetExampleTotalAlloyLossDifferenceAsync(), Is.EqualTo(300));
            Assert.That(await page.GetExampleTotalAlloyLossAccurateDifferenceAsync(), Is.EqualTo(270));
        });
    }
}