#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDBBeadStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJDB.BeadStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDBBeadStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationBeadStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationBeadStateLedgerContract(
		TEXT("validation-bead-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDBOngoingStateCelebrationBoundaryTest,
	"HyperTwist.Validation.PhaseJDB.OngoingStateCelebrationBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDBOngoingStateCelebrationBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateCelebrationBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateCelebrationBoundary(
		TEXT("validation-ongoing-state-celebration-boundary"),
		Boundary);

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

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

	return true;
}
