#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCTMutuleStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJCT.MutuleStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCTMutuleStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationMutuleStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationMutuleStateLedgerContract(
		TEXT("validation-mutule-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCTOngoingStateDeferenceBoundaryTest,
	"HyperTwist.Validation.PhaseJCT.OngoingStateDeferenceBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCTOngoingStateDeferenceBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateDeferenceBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateDeferenceBoundary(
		TEXT("validation-ongoing-state-deference-boundary"),
		Boundary);

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

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

	return true;
}
