#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJGMPhelonionStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJGM.PhelonionStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJGMPhelonionStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationPhelonionStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationPhelonionStateLedgerContract(
		TEXT("validation-phelonion-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJGMOngoingStateRiassaBoundaryTest,
	"HyperTwist.Validation.PhaseJGM.OngoingStateRiassaBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJGMOngoingStateRiassaBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateRiassaBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateRiassaBoundary(
		TEXT("validation-ongoing-state-riassa-boundary"),
		Boundary);

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

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

	return true;
}
