#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDXBolsterStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJDX.BolsterStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDXBolsterStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationBolsterStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationBolsterStateLedgerContract(
		TEXT("validation-bolster-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDXOngoingStateConcordBoundaryTest,
	"HyperTwist.Validation.PhaseJDX.OngoingStateConcordBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDXOngoingStateConcordBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateConcordBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateConcordBoundary(
		TEXT("validation-ongoing-state-concord-boundary"),
		Boundary);

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

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

	return true;
}
