#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBZTrestleStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJBZ.TrestleStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBZTrestleStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationTrestleStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationTrestleStateLedgerContract(
		TEXT("validation-trestle-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBZOngoingStateCurtainCallBoundaryTest,
	"HyperTwist.Validation.PhaseJBZ.OngoingStateCurtainCallBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBZOngoingStateCurtainCallBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateCurtainCallBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateCurtainCallBoundary(
		TEXT("validation-ongoing-state-curtain-call-boundary"),
		Boundary);

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

	TestEqual(
		TEXT("The validation ongoing-state curtain-call boundary id must stay stable."),
		Boundary.BoundaryId,
		FString(TEXT("validation-ongoing-state-curtain-call-boundary")));
	TestTrue(
		TEXT("The validation ongoing-state curtain-call boundary must preserve manual-waiver curtain-calls."),
		Boundary.CurtainCallIds.Contains(TEXT("ongoing-curtain-call/manual-waiver-curtain-call")));
	TestTrue(
		TEXT("The validation ongoing-state curtain-call boundary must preserve the bounded ongoing-state curtain-call surface."),
		Boundary.CurtainCallSurfaceTags.Contains(TEXT("bounded ongoing-state curtain-call")));
	TestTrue(
		TEXT("The validation ongoing-state curtain-call boundary must preserve the no-generic-ongoing-curtain-call-platform guard."),
		Boundary.CurtainCallGuardTags.Contains(TEXT("no-generic-ongoing-curtain-call-platform guard")));
	TestTrue(
		TEXT("The validation ongoing-state curtain-call boundary must keep generic ongoing curtain-call platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing curtain-call platform ownership")));

	return true;
}
