#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCVCymatiumStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJCV.CymatiumStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCVCymatiumStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationCymatiumStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationCymatiumStateLedgerContract(
		TEXT("validation-cymatium-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCVOngoingStateVenerationBoundaryTest,
	"HyperTwist.Validation.PhaseJCV.OngoingStateVenerationBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCVOngoingStateVenerationBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateVenerationBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateVenerationBoundary(
		TEXT("validation-ongoing-state-veneration-boundary"),
		Boundary);

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

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

	return true;
}
