#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBVMoatStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJBV.MoatStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBVMoatStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationMoatStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationMoatStateLedgerContract(
		TEXT("validation-moat-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBVOngoingStateEpilogueBoundaryTest,
	"HyperTwist.Validation.PhaseJBV.OngoingStateEpilogueBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBVOngoingStateEpilogueBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateEpilogueBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateEpilogueBoundary(
		TEXT("validation-ongoing-state-epilogue-boundary"),
		Boundary);

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

	TestEqual(
		TEXT("The validation ongoing-state epilogue boundary id must stay stable."),
		Boundary.BoundaryId,
		FString(TEXT("validation-ongoing-state-epilogue-boundary")));
	TestTrue(
		TEXT("The validation ongoing-state epilogue boundary must preserve manual-waiver epilogues."),
		Boundary.EpilogueIds.Contains(TEXT("ongoing-epilogue/manual-waiver-epilogue")));
	TestTrue(
		TEXT("The validation ongoing-state epilogue boundary must preserve the bounded ongoing-state epilogue surface."),
		Boundary.EpilogueSurfaceTags.Contains(TEXT("bounded ongoing-state epilogue")));
	TestTrue(
		TEXT("The validation ongoing-state epilogue boundary must preserve the no-generic-ongoing-epilogue-platform guard."),
		Boundary.EpilogueGuardTags.Contains(TEXT("no-generic-ongoing-epilogue-platform guard")));
	TestTrue(
		TEXT("The validation ongoing-state epilogue boundary must keep generic ongoing epilogue platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing epilogue platform ownership")));

	return true;
}
