#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDZShaftStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJDZ.ShaftStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDZShaftStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationShaftStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationShaftStateLedgerContract(
		TEXT("validation-shaft-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDZOngoingStateUnityBoundaryTest,
	"HyperTwist.Validation.PhaseJDZ.OngoingStateUnityBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDZOngoingStateUnityBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateUnityBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateUnityBoundary(
		TEXT("validation-ongoing-state-unity-boundary"),
		Boundary);

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

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

	return true;
}
