#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEHRostrumStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJEH.RostrumStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEHRostrumStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationRostrumStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationRostrumStateLedgerContract(
		TEXT("validation-rostrum-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEHOngoingStateAssemblyBoundaryTest,
	"HyperTwist.Validation.PhaseJEH.OngoingStateAssemblyBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEHOngoingStateAssemblyBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateAssemblyBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateAssemblyBoundary(
		TEXT("validation-ongoing-state-assembly-boundary"),
		Boundary);

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

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

	return true;
}
