#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEPSediliaStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJEP.SediliaStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEPSediliaStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationSediliaStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationSediliaStateLedgerContract(
		TEXT("validation-sedilia-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEPOngoingStateChapterBoundaryTest,
	"HyperTwist.Validation.PhaseJEP.OngoingStateChapterBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEPOngoingStateChapterBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateChapterBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateChapterBoundary(
		TEXT("validation-ongoing-state-chapter-boundary"),
		Boundary);

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

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

	return true;
}
