// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJMResumedStateCheckpointContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJM.ResumedStateCheckpoints",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJMResumedStateCheckpointContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationResumedStateCheckpointContract Contract;
	TestTrue(
		TEXT("The validation resumed-state checkpoint contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationResumedStateCheckpointContract(
			TEXT("validation-resumed-state-checkpoint-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The validation resumed-state checkpoint contract id must stay stable."),
		Contract.ContractId,
		TEXT("validation-resumed-state-checkpoint-contract")
	);
	TestTrue(
		TEXT("The validation resumed-state checkpoint contract must preserve benchmark-drift resumed checkpoints."),
		Contract.CheckpointIds.Contains(TEXT("resumed-checkpoint/benchmark-drift-resumed"))
	);
	TestTrue(
		TEXT("The validation resumed-state checkpoint contract must preserve the bounded resumed-state checkpoint surface."),
		Contract.CheckpointSurfaceTags.Contains(TEXT("bounded resumed-state checkpoint"))
	);
	TestTrue(
		TEXT("The validation resumed-state checkpoint contract must preserve the no-generic-resume-engine guard."),
		Contract.ResumeGuardTags.Contains(TEXT("no-generic-resume-engine guard"))
	);
	TestTrue(
		TEXT("The validation resumed-state checkpoint contract must keep generic resume engine ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic resume engine ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJMContinuationAttestationBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJM.ContinuationAttestations",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJMContinuationAttestationBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationContinuationAttestationBoundary Boundary;
	TestTrue(
		TEXT("The validation continuation-attestation boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationContinuationAttestationBoundary(
			TEXT("validation-continuation-attestation-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The validation continuation-attestation boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-continuation-attestation-boundary")
	);
	TestTrue(
		TEXT("The validation continuation-attestation boundary must preserve manual-waiver continuation attestations."),
		Boundary.AttestationIds.Contains(TEXT("continuation-attestation/manual-waiver-continue"))
	);
	TestTrue(
		TEXT("The validation continuation-attestation boundary must preserve the bounded continuation attestation surface."),
		Boundary.AttestationSurfaceTags.Contains(TEXT("bounded continuation attestation"))
	);
	TestTrue(
		TEXT("The validation continuation-attestation boundary must preserve the no-generic-continuation-workflow guard."),
		Boundary.ContinuationGuardTags.Contains(TEXT("no-generic-continuation-workflow guard"))
	);
	TestTrue(
		TEXT("The validation continuation-attestation boundary must keep generic continuation workflow ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic continuation workflow ownership"))
	);
	return true;
}

#endif
