#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJENCathedraStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJEN.CathedraStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJENCathedraStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationCathedraStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationCathedraStateLedgerContract(
		TEXT("validation-cathedra-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJENOngoingStateSynodBoundaryTest,
	"HyperTwist.Validation.PhaseJEN.OngoingStateSynodBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJENOngoingStateSynodBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateSynodBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateSynodBoundary(
		TEXT("validation-ongoing-state-synod-boundary"),
		Boundary);

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

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

	return true;
}
