#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCLCorniceStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJCL.CorniceStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCLCorniceStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationCorniceStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationCorniceStateLedgerContract(
		TEXT("validation-cornice-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCLOngoingStateHonorBoundaryTest,
	"HyperTwist.Validation.PhaseJCL.OngoingStateHonorBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCLOngoingStateHonorBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateHonorBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateHonorBoundary(
		TEXT("validation-ongoing-state-honor-boundary"),
		Boundary);

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

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

	return true;
}
