#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBXViaductStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJBX.ViaductStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBXViaductStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationViaductStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationViaductStateLedgerContract(
		TEXT("validation-viaduct-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBXOngoingStateEncoreBoundaryTest,
	"HyperTwist.Validation.PhaseJBX.OngoingStateEncoreBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBXOngoingStateEncoreBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateEncoreBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateEncoreBoundary(
		TEXT("validation-ongoing-state-encore-boundary"),
		Boundary);

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

	TestEqual(
		TEXT("The validation ongoing-state encore boundary id must stay stable."),
		Boundary.BoundaryId,
		FString(TEXT("validation-ongoing-state-encore-boundary")));
	TestTrue(
		TEXT("The validation ongoing-state encore boundary must preserve manual-waiver encores."),
		Boundary.EncoreIds.Contains(TEXT("ongoing-encore/manual-waiver-encore")));
	TestTrue(
		TEXT("The validation ongoing-state encore boundary must preserve the bounded ongoing-state encore surface."),
		Boundary.EncoreSurfaceTags.Contains(TEXT("bounded ongoing-state encore")));
	TestTrue(
		TEXT("The validation ongoing-state encore boundary must preserve the no-generic-ongoing-encore-platform guard."),
		Boundary.EncoreGuardTags.Contains(TEXT("no-generic-ongoing-encore-platform guard")));
	TestTrue(
		TEXT("The validation ongoing-state encore boundary must keep generic ongoing encore platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing encore platform ownership")));

	return true;
}
