#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFYMozzettaStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJFY.MozzettaStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFYMozzettaStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationMozzettaStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationMozzettaStateLedgerContract(
		TEXT("validation-mozzetta-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFYOngoingStateRochetBoundaryTest,
	"HyperTwist.Validation.PhaseJFY.OngoingStateRochetBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFYOngoingStateRochetBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateRochetBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateRochetBoundary(
		TEXT("validation-ongoing-state-rochet-boundary"),
		Boundary);

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

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

	return true;
}
