#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCDKeystoneStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJCD.KeystoneStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCDKeystoneStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationKeystoneStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationKeystoneStateLedgerContract(
		TEXT("validation-keystone-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCDOngoingStateAcclamationBoundaryTest,
	"HyperTwist.Validation.PhaseJCD.OngoingStateAcclamationBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCDOngoingStateAcclamationBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateAcclamationBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateAcclamationBoundary(
		TEXT("validation-ongoing-state-acclamation-boundary"),
		Boundary);

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

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

	return true;
}
