#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJGVDiskosStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJGV.DiskosStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJGVDiskosStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationDiskosStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationDiskosStateLedgerContract(
		TEXT("validation-diskos-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJGVOngoingStateKalymmaBoundaryTest,
	"HyperTwist.Validation.PhaseJGV.OngoingStateKalymmaBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJGVOngoingStateKalymmaBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateKalymmaBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateKalymmaBoundary(
		TEXT("validation-ongoing-state-kalymma-boundary"),
		Boundary);

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

	TestEqual(
		TEXT("The validation ongoing-state kalymma boundary id must stay stable."),
		Boundary.BoundaryId,
		FString(TEXT("validation-ongoing-state-kalymma-boundary")));
	TestTrue(
		TEXT("The validation ongoing-state kalymma boundary must preserve reviewer-waiver kalymma anchors."),
		Boundary.KalymmaIds.Contains(TEXT("ongoing-kalymma/reviewer-waiver-kalymma")));
	TestTrue(
		TEXT("The validation ongoing-state kalymma boundary must preserve the bounded ongoing-state kalymma surface."),
		Boundary.KalymmaSurfaceTags.Contains(TEXT("bounded ongoing-state kalymma")));
	TestTrue(
		TEXT("The validation ongoing-state kalymma boundary must preserve the no-generic-ongoing-kalymma-platform guard."),
		Boundary.KalymmaGuardTags.Contains(TEXT("no-generic-ongoing-kalymma-platform guard")));
	TestTrue(
		TEXT("The validation ongoing-state kalymma boundary must keep generic ongoing kalymma platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing kalymma platform ownership")));

	return true;
}
