#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEDStylobateStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJED.StylobateStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEDStylobateStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationStylobateStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationStylobateStateLedgerContract(
		TEXT("validation-stylobate-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEDOngoingStateConsortiumBoundaryTest,
	"HyperTwist.Validation.PhaseJED.OngoingStateConsortiumBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEDOngoingStateConsortiumBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateConsortiumBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateConsortiumBoundary(
		TEXT("validation-ongoing-state-consortium-boundary"),
		Boundary);

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

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

	return true;
}
