#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFSAlbStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJFS.AlbStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFSAlbStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationAlbStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationAlbStateLedgerContract(
		TEXT("validation-alb-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFSOngoingStateChasubleBoundaryTest,
	"HyperTwist.Validation.PhaseJFS.OngoingStateChasubleBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFSOngoingStateChasubleBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateChasubleBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateChasubleBoundary(
		TEXT("validation-ongoing-state-chasuble-boundary"),
		Boundary);

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

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

	return true;
}
