// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJXNestedStateLedgerContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJX.NestedStateLedgers",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJXNestedStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationNestedStateLedgerContract Contract;
	TestTrue(
		TEXT("The validation nested-state ledger contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationNestedStateLedgerContract(
			TEXT("validation-nested-state-ledger-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The validation nested-state ledger contract id must stay stable."),
		Contract.ContractId,
		TEXT("validation-nested-state-ledger-contract")
	);
	TestTrue(
		TEXT("The validation nested-state ledger contract must preserve continuity-context nested entries."),
		Contract.LedgerEntryIds.Contains(TEXT("nested-state-ledger/continuity-context-nested"))
	);
	TestTrue(
		TEXT("The validation nested-state ledger contract must preserve the bounded nested-state ledger surface."),
		Contract.LedgerSurfaceTags.Contains(TEXT("bounded nested-state ledger"))
	);
	TestTrue(
		TEXT("The validation nested-state ledger contract must preserve the no-generic-nested-state-platform guard."),
		Contract.NestedGuardTags.Contains(TEXT("no-generic-nested-state-platform guard"))
	);
	TestTrue(
		TEXT("The validation nested-state ledger contract must keep generic nested-state platform ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic nested-state platform ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJXOngoingStateHarmonizationBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJX.OngoingStateHarmonizations",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJXOngoingStateHarmonizationBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateHarmonizationBoundary Boundary;
	TestTrue(
		TEXT("The validation ongoing-state harmonization boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateHarmonizationBoundary(
			TEXT("validation-ongoing-state-harmonization-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The validation ongoing-state harmonization boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-ongoing-state-harmonization-boundary")
	);
	TestTrue(
		TEXT("The validation ongoing-state harmonization boundary must preserve benchmark-drift harmonizations."),
		Boundary.HarmonizationIds.Contains(TEXT("ongoing-harmonization/benchmark-drift-harmonized"))
	);
	TestTrue(
		TEXT("The validation ongoing-state harmonization boundary must preserve the bounded ongoing-state harmonization surface."),
		Boundary.HarmonizationSurfaceTags.Contains(TEXT("bounded ongoing-state harmonization"))
	);
	TestTrue(
		TEXT("The validation ongoing-state harmonization boundary must preserve the no-generic-ongoing-harmonization-platform guard."),
		Boundary.HarmonizationGuardTags.Contains(TEXT("no-generic-ongoing-harmonization-platform guard"))
	);
	TestTrue(
		TEXT("The validation ongoing-state harmonization boundary must keep generic ongoing harmonization platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing harmonization platform ownership"))
	);
	return true;
}

#endif
