#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDTAbacusStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJDT.AbacusStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDTAbacusStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationAbacusStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationAbacusStateLedgerContract(
		TEXT("validation-abacus-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDTOngoingStateFraternityBoundaryTest,
	"HyperTwist.Validation.PhaseJDT.OngoingStateFraternityBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDTOngoingStateFraternityBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateFraternityBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateFraternityBoundary(
		TEXT("validation-ongoing-state-fraternity-boundary"),
		Boundary);

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

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

	return true;
}
