#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJHALavidaStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJHA.LavidaStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJHALavidaStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationLavidaStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationLavidaStateLedgerContract(
		TEXT("validation-lavida-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJHAOngoingStateSudarionBoundaryTest,
	"HyperTwist.Validation.PhaseJHA.OngoingStateSudarionBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJHAOngoingStateSudarionBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateSudarionBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateSudarionBoundary(
		TEXT("validation-ongoing-state-sudarion-boundary"),
		Boundary);

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

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

	return true;
}
