#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFRAmiceStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJFR.AmiceStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFRAmiceStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationAmiceStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationAmiceStateLedgerContract(
		TEXT("validation-amice-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFROngoingStateStoleBoundaryTest,
	"HyperTwist.Validation.PhaseJFR.OngoingStateStoleBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFROngoingStateStoleBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateStoleBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateStoleBoundary(
		TEXT("validation-ongoing-state-stole-boundary"),
		Boundary);

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

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

	return true;
}
