#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFQLunulaStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJFQ.LunulaStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFQLunulaStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationLunulaStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationLunulaStateLedgerContract(
		TEXT("validation-lunula-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFQOngoingStateCopeBoundaryTest,
	"HyperTwist.Validation.PhaseJFQ.OngoingStateCopeBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFQOngoingStateCopeBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateCopeBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateCopeBoundary(
		TEXT("validation-ongoing-state-cope-boundary"),
		Boundary);

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

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

	return true;
}
