#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCJCapitalStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJCJ.CapitalStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCJCapitalStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationCapitalStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationCapitalStateLedgerContract(
		TEXT("validation-capital-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCJOngoingStatePlauditBoundaryTest,
	"HyperTwist.Validation.PhaseJCJ.OngoingStatePlauditBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCJOngoingStatePlauditBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStatePlauditBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStatePlauditBoundary(
		TEXT("validation-ongoing-state-plaudit-boundary"),
		Boundary);

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

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

	return true;
}
