#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCRRegulaStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJCR.RegulaStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCRRegulaStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationRegulaStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationRegulaStateLedgerContract(
		TEXT("validation-regula-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCROngoingStateRegardBoundaryTest,
	"HyperTwist.Validation.PhaseJCR.OngoingStateRegardBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCROngoingStateRegardBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateRegardBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateRegardBoundary(
		TEXT("validation-ongoing-state-regard-boundary"),
		Boundary);

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

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

	return true;
}
