#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEXRetableStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJEX.RetableStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEXRetableStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationRetableStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationRetableStateLedgerContract(
		TEXT("validation-retable-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEXOngoingStateIconostasisBoundaryTest,
	"HyperTwist.Validation.PhaseJEX.OngoingStateIconostasisBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEXOngoingStateIconostasisBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateIconostasisBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateIconostasisBoundary(
		TEXT("validation-ongoing-state-iconostasis-boundary"),
		Boundary);

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

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

	return true;
}
