#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDJAnnuletStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJDJ.AnnuletStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDJAnnuletStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationAnnuletStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationAnnuletStateLedgerContract(
		TEXT("validation-annulet-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDJOngoingStateJoyBoundaryTest,
	"HyperTwist.Validation.PhaseJDJ.OngoingStateJoyBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDJOngoingStateJoyBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateJoyBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateJoyBoundary(
		TEXT("validation-ongoing-state-joy-boundary"),
		Boundary);

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

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

	return true;
}
