#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJGTDikerionStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJGT.DikerionStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJGTDikerionStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationDikerionStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationDikerionStateLedgerContract(
		TEXT("validation-dikerion-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJGTOngoingStateTrikerionBoundaryTest,
	"HyperTwist.Validation.PhaseJGT.OngoingStateTrikerionBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJGTOngoingStateTrikerionBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateTrikerionBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateTrikerionBoundary(
		TEXT("validation-ongoing-state-trikerion-boundary"),
		Boundary);

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

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

	return true;
}
