#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJELAmboStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJEL.AmboStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJELAmboStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationAmboStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationAmboStateLedgerContract(
		TEXT("validation-ambo-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJELOngoingStateQuorumBoundaryTest,
	"HyperTwist.Validation.PhaseJEL.OngoingStateQuorumBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJELOngoingStateQuorumBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateQuorumBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateQuorumBoundary(
		TEXT("validation-ongoing-state-quorum-boundary"),
		Boundary);

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

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

	return true;
}
