#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFVMitreStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJFV.MitreStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFVMitreStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationMitreStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationMitreStateLedgerContract(
		TEXT("validation-mitre-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFVOngoingStateCrosierBoundaryTest,
	"HyperTwist.Validation.PhaseJFV.OngoingStateCrosierBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFVOngoingStateCrosierBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateCrosierBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateCrosierBoundary(
		TEXT("validation-ongoing-state-crosier-boundary"),
		Boundary);

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

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

	return true;
}
