#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCPMetopeStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJCP.MetopeStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCPMetopeStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationMetopeStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationMetopeStateLedgerContract(
		TEXT("validation-metope-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCPOngoingStateAdmirationBoundaryTest,
	"HyperTwist.Validation.PhaseJCP.OngoingStateAdmirationBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCPOngoingStateAdmirationBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateAdmirationBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateAdmirationBoundary(
		TEXT("validation-ongoing-state-admiration-boundary"),
		Boundary);

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

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

	return true;
}
