#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJHCAnaphoraStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJHC.AnaphoraStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJHCAnaphoraStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationAnaphoraStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationAnaphoraStateLedgerContract(
		TEXT("validation-anaphora-state-ledger-contract"),
		Contract);

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

	TestEqual(
		TEXT("The validation anaphora-state ledger contract id must stay stable."),
		Contract.ContractId,
		FString(TEXT("validation-anaphora-state-ledger-contract")));
	TestTrue(
		TEXT("The validation anaphora-state ledger contract must be structurally valid."),
		Contract.IsStructurallyValid());
	TestTrue(
		TEXT("The validation anaphora-state ledger contract must carry first-party source attribution."),
		Contract.SourceAttribution.IsStructurallyValid());
	TestTrue(
		TEXT("The validation anaphora-state ledger contract must carry at least one ledger id."),
		Contract.LedgerIds.Num() > 0);
	TestTrue(
		TEXT("The validation anaphora-state ledger contract must carry at least one guard tag."),
		Contract.AnaphoraGuardTags.Num() > 0);
	TestTrue(
		TEXT("The validation anaphora-state ledger contract must carry at least one explicit exclusion."),
		Contract.ExplicitExclusions.Num() > 0);

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJHCOngoingStateEpiclesisBoundaryTest,
	"HyperTwist.Validation.PhaseJHC.OngoingStateEpiclesisBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJHCOngoingStateEpiclesisBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateEpiclesisBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateEpiclesisBoundary(
		TEXT("validation-ongoing-state-epiclesis-boundary"),
		Boundary);

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

	TestEqual(
		TEXT("The validation ongoing-state epiclesis boundary id must stay stable."),
		Boundary.BoundaryId,
		FString(TEXT("validation-ongoing-state-epiclesis-boundary")));
	TestTrue(
		TEXT("The validation ongoing-state epiclesis boundary must be structurally valid."),
		Boundary.IsStructurallyValid());
	TestTrue(
		TEXT("The validation ongoing-state epiclesis boundary must carry first-party source attribution."),
		Boundary.SourceAttribution.IsStructurallyValid());
	TestTrue(
		TEXT("The validation ongoing-state epiclesis boundary must carry at least one epiclesis id."),
		Boundary.EpiclesisIds.Num() > 0);
	TestTrue(
		TEXT("The validation ongoing-state epiclesis boundary must carry at least one guard tag."),
		Boundary.EpiclesisGuardTags.Num() > 0);
	TestTrue(
		TEXT("The validation ongoing-state epiclesis boundary must carry at least one explicit exclusion."),
		Boundary.ExplicitExclusions.Num() > 0);

	return true;
}
