#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFBSuperfrontalStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJFB.SuperfrontalStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFBSuperfrontalStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationSuperfrontalStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationSuperfrontalStateLedgerContract(
		TEXT("validation-superfrontal-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFBOngoingStateFairLinenBoundaryTest,
	"HyperTwist.Validation.PhaseJFB.OngoingStateFairLinenBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFBOngoingStateFairLinenBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateFairLinenBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateFairLinenBoundary(
		TEXT("validation-ongoing-state-fair-linen-boundary"),
		Boundary);

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

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

	return true;
}
