#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFZSurpliceStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJFZ.SurpliceStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFZSurpliceStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationSurpliceStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationSurpliceStateLedgerContract(
		TEXT("validation-surplice-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFZOngoingStateTippetBoundaryTest,
	"HyperTwist.Validation.PhaseJFZ.OngoingStateTippetBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFZOngoingStateTippetBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateTippetBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateTippetBoundary(
		TEXT("validation-ongoing-state-tippet-boundary"),
		Boundary);

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

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

	return true;
}
