// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJTAnchoredStateLedgerContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJT.AnchoredStateLedgers",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJTAnchoredStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationAnchoredStateLedgerContract Contract;
	TestTrue(
		TEXT("The validation anchored-state ledger contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationAnchoredStateLedgerContract(
			TEXT("validation-anchored-state-ledger-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The validation anchored-state ledger contract id must stay stable."),
		Contract.ContractId,
		TEXT("validation-anchored-state-ledger-contract")
	);
	TestTrue(
		TEXT("The validation anchored-state ledger contract must preserve benchmark-drift anchored ledger entries."),
		Contract.LedgerEntryIds.Contains(TEXT("anchored-state-ledger/benchmark-drift-anchored"))
	);
	TestTrue(
		TEXT("The validation anchored-state ledger contract must preserve the bounded anchored-state ledger surface."),
		Contract.LedgerSurfaceTags.Contains(TEXT("bounded anchored-state ledger"))
	);
	TestTrue(
		TEXT("The validation anchored-state ledger contract must preserve the no-generic-anchored-state-platform guard."),
		Contract.AnchoredGuardTags.Contains(TEXT("no-generic-anchored-state-platform guard"))
	);
	TestTrue(
		TEXT("The validation anchored-state ledger contract must keep generic anchored-state platform ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic anchored-state platform ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJTOngoingStateAffirmationBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJT.OngoingStateAffirmations",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJTOngoingStateAffirmationBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateAffirmationBoundary Boundary;
	TestTrue(
		TEXT("The validation ongoing-state affirmation boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateAffirmationBoundary(
			TEXT("validation-ongoing-state-affirmation-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The validation ongoing-state affirmation boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-ongoing-state-affirmation-boundary")
	);
	TestTrue(
		TEXT("The validation ongoing-state affirmation boundary must preserve manual-waiver affirmations."),
		Boundary.AffirmationIds.Contains(TEXT("ongoing-affirmation/manual-waiver-affirmed"))
	);
	TestTrue(
		TEXT("The validation ongoing-state affirmation boundary must preserve the bounded ongoing-state affirmation surface."),
		Boundary.AffirmationSurfaceTags.Contains(TEXT("bounded ongoing-state affirmation"))
	);
	TestTrue(
		TEXT("The validation ongoing-state affirmation boundary must preserve the no-generic-ongoing-affirmation-platform guard."),
		Boundary.AffirmationGuardTags.Contains(TEXT("no-generic-ongoing-affirmation-platform guard"))
	);
	TestTrue(
		TEXT("The validation ongoing-state affirmation boundary must keep generic ongoing affirmation platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing affirmation platform ownership"))
	);
	return true;
}

#endif
