#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDHAstragalStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJDH.AstragalStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDHAstragalStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationAstragalStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationAstragalStateLedgerContract(
		TEXT("validation-astragal-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDHOngoingStateGladnessBoundaryTest,
	"HyperTwist.Validation.PhaseJDH.OngoingStateGladnessBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDHOngoingStateGladnessBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateGladnessBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateGladnessBoundary(
		TEXT("validation-ongoing-state-gladness-boundary"),
		Boundary);

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

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

	return true;
}
