#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFLAumbryStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJFL.AumbryStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFLAumbryStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationAumbryStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationAumbryStateLedgerContract(
		TEXT("validation-aumbry-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFLOngoingStateTabernacleBoundaryTest,
	"HyperTwist.Validation.PhaseJFL.OngoingStateTabernacleBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFLOngoingStateTabernacleBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateTabernacleBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateTabernacleBoundary(
		TEXT("validation-ongoing-state-tabernacle-boundary"),
		Boundary);

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

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

	return true;
}
