#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDVHypotrachelionStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJDV.HypotrachelionStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDVHypotrachelionStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationHypotrachelionStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationHypotrachelionStateLedgerContract(
		TEXT("validation-hypotrachelion-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDVOngoingStateAllianceBoundaryTest,
	"HyperTwist.Validation.PhaseJDV.OngoingStateAllianceBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDVOngoingStateAllianceBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateAllianceBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateAllianceBoundary(
		TEXT("validation-ongoing-state-alliance-boundary"),
		Boundary);

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

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

	return true;
}
