#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJGNKlobukStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJGN.KlobukStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJGNKlobukStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationKlobukStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationKlobukStateLedgerContract(
		TEXT("validation-klobuk-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJGNOngoingStateMandyasBoundaryTest,
	"HyperTwist.Validation.PhaseJGN.OngoingStateMandyasBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJGNOngoingStateMandyasBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateMandyasBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateMandyasBoundary(
		TEXT("validation-ongoing-state-mandyas-boundary"),
		Boundary);

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

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

	return true;
}
