#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFFPyxStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJFF.PyxStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFFPyxStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationPyxStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationPyxStateLedgerContract(
		TEXT("validation-pyx-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFFOngoingStateMonstranceBoundaryTest,
	"HyperTwist.Validation.PhaseJFF.OngoingStateMonstranceBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFFOngoingStateMonstranceBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateMonstranceBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateMonstranceBoundary(
		TEXT("validation-ongoing-state-monstrance-boundary"),
		Boundary);

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

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

	return true;
}
