#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCFPierStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJCF.PierStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCFPierStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationPierStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationPierStateLedgerContract(
		TEXT("validation-pier-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCFOngoingStateTributeBoundaryTest,
	"HyperTwist.Validation.PhaseJCF.OngoingStateTributeBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCFOngoingStateTributeBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateTributeBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateTributeBoundary(
		TEXT("validation-ongoing-state-tribute-boundary"),
		Boundary);

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

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

	return true;
}
