// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJQDurableStatePacketContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJQ.DurableStatePackets",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJQDurableStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationDurableStatePacketContract Contract;
	TestTrue(
		TEXT("The validation durable-state packet contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationDurableStatePacketContract(
			TEXT("validation-durable-state-packet-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The validation durable-state packet contract id must stay stable."),
		Contract.ContractId,
		TEXT("validation-durable-state-packet-contract")
	);
	TestTrue(
		TEXT("The validation durable-state packet contract must preserve benchmark-drift durable packets."),
		Contract.PacketIds.Contains(TEXT("durable-state-packet/benchmark-drift-durable"))
	);
	TestTrue(
		TEXT("The validation durable-state packet contract must preserve the bounded durable-state packet surface."),
		Contract.PacketSurfaceTags.Contains(TEXT("bounded durable-state packet"))
	);
	TestTrue(
		TEXT("The validation durable-state packet contract must preserve the no-generic-durability-platform guard."),
		Contract.DurabilityGuardTags.Contains(TEXT("no-generic-durability-platform guard"))
	);
	TestTrue(
		TEXT("The validation durable-state packet contract must keep generic durability platform ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic durability platform ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJQOngoingStateAttestationBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJQ.OngoingStateAttestations",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJQOngoingStateAttestationBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateAttestationBoundary Boundary;
	TestTrue(
		TEXT("The validation ongoing-state attestation boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateAttestationBoundary(
			TEXT("validation-ongoing-state-attestation-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The validation ongoing-state attestation boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-ongoing-state-attestation-boundary")
	);
	TestTrue(
		TEXT("The validation ongoing-state attestation boundary must preserve manual-waiver attestations."),
		Boundary.AttestationIds.Contains(TEXT("ongoing-attestation/manual-waiver-attested"))
	);
	TestTrue(
		TEXT("The validation ongoing-state attestation boundary must preserve the bounded ongoing-state attestation surface."),
		Boundary.AttestationSurfaceTags.Contains(TEXT("bounded ongoing-state attestation"))
	);
	TestTrue(
		TEXT("The validation ongoing-state attestation boundary must preserve the no-generic-ongoing-attestation-platform guard."),
		Boundary.OngoingAttestationGuardTags.Contains(TEXT("no-generic-ongoing-attestation-platform guard"))
	);
	TestTrue(
		TEXT("The validation ongoing-state attestation boundary must keep generic ongoing attestation platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing attestation platform ownership"))
	);
	return true;
}

#endif
