#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJGDFerraioloStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJGD.FerraioloStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJGDFerraioloStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationFerraioloStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationFerraioloStateLedgerContract(
		TEXT("validation-ferraiolo-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJGDOngoingStateMantellettaBoundaryTest,
	"HyperTwist.Validation.PhaseJGD.OngoingStateMantellettaBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJGDOngoingStateMantellettaBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateMantellettaBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateMantellettaBoundary(
		TEXT("validation-ongoing-state-mantelletta-boundary"),
		Boundary);

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

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

	return true;
}
