#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJGZLoncheStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJGZ.LoncheStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJGZLoncheStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationLoncheStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationLoncheStateLedgerContract(
		TEXT("validation-lonche-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJGZOngoingStateLanceBoundaryTest,
	"HyperTwist.Validation.PhaseJGZ.OngoingStateLanceBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJGZOngoingStateLanceBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateLanceBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateLanceBoundary(
		TEXT("validation-ongoing-state-lance-boundary"),
		Boundary);

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

	TestEqual(
		TEXT("The validation ongoing-state lance boundary id must stay stable."),
		Boundary.BoundaryId,
		FString(TEXT("validation-ongoing-state-lance-boundary")));
	TestTrue(
		TEXT("The validation ongoing-state lance boundary must preserve reviewer-waiver lance anchors."),
		Boundary.LanceIds.Contains(TEXT("ongoing-lance/reviewer-waiver-lance")));
	TestTrue(
		TEXT("The validation ongoing-state lance boundary must preserve the bounded ongoing-state lance surface."),
		Boundary.LanceSurfaceTags.Contains(TEXT("bounded ongoing-state lance")));
	TestTrue(
		TEXT("The validation ongoing-state lance boundary must preserve the no-generic-ongoing-lance-platform guard."),
		Boundary.LanceGuardTags.Contains(TEXT("no-generic-ongoing-lance-platform guard")));
	TestTrue(
		TEXT("The validation ongoing-state lance boundary must keep generic ongoing lance platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing lance platform ownership")));

	return true;
}
