#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCHPilasterStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJCH.PilasterStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCHPilasterStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationPilasterStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationPilasterStateLedgerContract(
		TEXT("validation-pilaster-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCHOngoingStateSaluteBoundaryTest,
	"HyperTwist.Validation.PhaseJCH.OngoingStateSaluteBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCHOngoingStateSaluteBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateSaluteBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateSaluteBoundary(
		TEXT("validation-ongoing-state-salute-boundary"),
		Boundary);

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

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

	return true;
}
