// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCEvidenceExportContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJC.EvidenceExports",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCEvidenceExportContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationEvidenceExportContract Contract;
	TestTrue(
		TEXT("The validation-evidence export contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationEvidenceExportContract(
			TEXT("validation-evidence-export-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The validation-evidence export contract id must stay stable."),
		Contract.ContractId,
		TEXT("validation-evidence-export-contract")
	);
	TestTrue(
		TEXT("The validation-evidence export contract must preserve validation summary JSON export."),
		Contract.ExportSurfaceIds.Contains(TEXT("evidence-export/validation-summary-json"))
	);
	TestTrue(
		TEXT("The validation-evidence export contract must preserve replay-integrity evidence serialization."),
		Contract.EvidenceSurfaceTags.Contains(TEXT("replay-integrity evidence serialization"))
	);
	TestTrue(
		TEXT("The validation-evidence export contract must preserve stable field ordering guard."),
		Contract.SerializationGuardTags.Contains(TEXT("stable field ordering guard"))
	);
	TestTrue(
		TEXT("The validation-evidence export contract must keep cross-product telemetry ingestion ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("cross-product telemetry ingestion ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCBenchmarkFixturePacketBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJC.FixturePackets",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCBenchmarkFixturePacketBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingBenchmarkFixturePacketBoundary Boundary;
	TestTrue(
		TEXT("The benchmark-fixture packet boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledBenchmarkFixturePacketBoundary(
			TEXT("validation-benchmark-fixture-packet-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The benchmark-fixture packet boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-benchmark-fixture-packet-boundary")
	);
	TestTrue(
		TEXT("The benchmark-fixture packet boundary must preserve replay-integrity-minimal fixture packets."),
		Boundary.FixturePacketIds.Contains(TEXT("fixture-packet/replay-integrity-minimal"))
	);
	TestTrue(
		TEXT("The benchmark-fixture packet boundary must preserve reproducible benchmark input packets."),
		Boundary.FixtureSurfaceTags.Contains(TEXT("reproducible benchmark input packet"))
	);
	TestTrue(
		TEXT("The benchmark-fixture packet boundary must preserve no-randomized-fixture-drift guard."),
		Boundary.ReproducibilityGuardTags.Contains(TEXT("no-randomized-fixture-drift guard"))
	);
	TestTrue(
		TEXT("The benchmark-fixture packet boundary must keep cross-product test-fixture registry ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("cross-product test-fixture registry ownership"))
	);
	return true;
}

#endif
