#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDDCavettoStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJDD.CavettoStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDDCavettoStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationCavettoStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationCavettoStateLedgerContract(
		TEXT("validation-cavetto-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDDOngoingStateRejoicingBoundaryTest,
	"HyperTwist.Validation.PhaseJDD.OngoingStateRejoicingBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDDOngoingStateRejoicingBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateRejoicingBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateRejoicingBoundary(
		TEXT("validation-ongoing-state-rejoicing-boundary"),
		Boundary);

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

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

	return true;
}
