#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJERStallStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJER.StallStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJERStallStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationStallStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationStallStateLedgerContract(
		TEXT("validation-stall-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEROngoingStateConsistoryBoundaryTest,
	"HyperTwist.Validation.PhaseJER.OngoingStateConsistoryBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEROngoingStateConsistoryBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateConsistoryBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateConsistoryBoundary(
		TEXT("validation-ongoing-state-consistory-boundary"),
		Boundary);

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

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

	return true;
}
