#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEBPlinthStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJEB.PlinthStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEBPlinthStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationPlinthStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationPlinthStateLedgerContract(
		TEXT("validation-plinth-state-ledger-contract"),
		Contract);

	TestTrue(
		TEXT("The validation plinth-state ledger contract must resolve from the runtime library."),
		bResolved);
	if (!bResolved)
	{
		return false;
	}

	TestEqual(
		TEXT("The validation plinth-state ledger contract id must stay stable."),
		Contract.ContractId,
		FString(TEXT("validation-plinth-state-ledger-contract")));
	TestTrue(
		TEXT("The validation plinth-state ledger contract must preserve benchmark-drift plinth ledgers."),
		Contract.LedgerIds.Contains(TEXT("plinth-state-ledger/benchmark-drift-plinth")));
	TestTrue(
		TEXT("The validation plinth-state ledger contract must preserve the bounded plinth-state ledger surface."),
		Contract.LedgerSurfaceTags.Contains(TEXT("bounded plinth-state ledger")));
	TestTrue(
		TEXT("The validation plinth-state ledger contract must preserve the no-generic-plinth-state-platform guard."),
		Contract.PlinthGuardTags.Contains(TEXT("no-generic-plinth-state-platform guard")));
	TestTrue(
		TEXT("The validation plinth-state ledger contract must keep generic plinth-state platform ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic plinth-state platform ownership")));

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEBOngoingStateCoalitionBoundaryTest,
	"HyperTwist.Validation.PhaseJEB.OngoingStateCoalitionBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEBOngoingStateCoalitionBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateCoalitionBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateCoalitionBoundary(
		TEXT("validation-ongoing-state-coalition-boundary"),
		Boundary);

	TestTrue(
		TEXT("The validation ongoing-state coalition boundary must resolve from the runtime library."),
		bResolved);
	if (!bResolved)
	{
		return false;
	}

	TestEqual(
		TEXT("The validation ongoing-state coalition boundary id must stay stable."),
		Boundary.BoundaryId,
		FString(TEXT("validation-ongoing-state-coalition-boundary")));
	TestTrue(
		TEXT("The validation ongoing-state coalition boundary must preserve manual-waiver coalition anchors."),
		Boundary.CoalitionIds.Contains(TEXT("ongoing-coalition/manual-waiver-coalition")));
	TestTrue(
		TEXT("The validation ongoing-state coalition boundary must preserve the bounded ongoing-state coalition surface."),
		Boundary.CoalitionSurfaceTags.Contains(TEXT("bounded ongoing-state coalition")));
	TestTrue(
		TEXT("The validation ongoing-state coalition boundary must preserve the no-generic-ongoing-coalition-platform guard."),
		Boundary.CoalitionGuardTags.Contains(TEXT("no-generic-ongoing-coalition-platform guard")));
	TestTrue(
		TEXT("The validation ongoing-state coalition boundary must keep generic ongoing coalition platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing coalition platform ownership")));

	return true;
}
