#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCBArchStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJCB.ArchStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCBArchStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationArchStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationArchStateLedgerContract(
		TEXT("validation-arch-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCBOngoingStateOvationBoundaryTest,
	"HyperTwist.Validation.PhaseJCB.OngoingStateOvationBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCBOngoingStateOvationBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateOvationBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateOvationBoundary(
		TEXT("validation-ongoing-state-ovation-boundary"),
		Boundary);

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

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

	return true;
}
