// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJZStackedStateLedgerContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJZ.StackedStateLedgers",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJZStackedStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationStackedStateLedgerContract Contract;
	TestTrue(
		TEXT("The validation stacked-state ledger contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationStackedStateLedgerContract(
			TEXT("validation-stacked-state-ledger-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The validation stacked-state ledger contract id must stay stable."),
		Contract.ContractId,
		TEXT("validation-stacked-state-ledger-contract")
	);
	TestTrue(
		TEXT("The validation stacked-state ledger contract must preserve benchmark-drift stacked entries."),
		Contract.LedgerEntryIds.Contains(TEXT("stacked-state-ledger/benchmark-drift-stacked"))
	);
	TestTrue(
		TEXT("The validation stacked-state ledger contract must preserve the bounded stacked-state ledger surface."),
		Contract.LedgerSurfaceTags.Contains(TEXT("bounded stacked-state ledger"))
	);
	TestTrue(
		TEXT("The validation stacked-state ledger contract must preserve the no-generic-stacked-state-platform guard."),
		Contract.StackedGuardTags.Contains(TEXT("no-generic-stacked-state-platform guard"))
	);
	TestTrue(
		TEXT("The validation stacked-state ledger contract must keep generic stacked-state platform ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic stacked-state platform ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJZOngoingStateConvergenceBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJZ.OngoingStateConvergences",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJZOngoingStateConvergenceBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateConvergenceBoundary Boundary;
	TestTrue(
		TEXT("The validation ongoing-state convergence boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateConvergenceBoundary(
			TEXT("validation-ongoing-state-convergence-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The validation ongoing-state convergence boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-ongoing-state-convergence-boundary")
	);
	TestTrue(
		TEXT("The validation ongoing-state convergence boundary must preserve manual-waiver convergences."),
		Boundary.ConvergenceIds.Contains(TEXT("ongoing-convergence/manual-waiver-converged"))
	);
	TestTrue(
		TEXT("The validation ongoing-state convergence boundary must preserve the bounded ongoing-state convergence surface."),
		Boundary.ConvergenceSurfaceTags.Contains(TEXT("bounded ongoing-state convergence"))
	);
	TestTrue(
		TEXT("The validation ongoing-state convergence boundary must preserve the no-generic-ongoing-convergence-platform guard."),
		Boundary.ConvergenceGuardTags.Contains(TEXT("no-generic-ongoing-convergence-platform guard"))
	);
	TestTrue(
		TEXT("The validation ongoing-state convergence boundary must keep generic ongoing convergence platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing convergence platform ownership"))
	);
	return true;
}

#endif
