#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEVSanctuaryStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJEV.SanctuaryStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEVSanctuaryStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationSanctuaryStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationSanctuaryStateLedgerContract(
		TEXT("validation-sanctuary-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEVOngoingStateApseBoundaryTest,
	"HyperTwist.Validation.PhaseJEV.OngoingStateApseBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEVOngoingStateApseBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateApseBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateApseBoundary(
		TEXT("validation-ongoing-state-apse-boundary"),
		Boundary);

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

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

	return true;
}
