// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJAUCorrugatedStatePacketContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJAU.CorrugatedStatePackets",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

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

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJAUOngoingStateTraceBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJAU.OngoingStateTraces",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJAUOngoingStateTraceBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateTraceBoundary Boundary;
	TestTrue(
		TEXT("The validation ongoing-state trace boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateTraceBoundary(
			TEXT("validation-ongoing-state-trace-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The validation ongoing-state trace boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-ongoing-state-trace-boundary")
	);
	TestTrue(
		TEXT("The validation ongoing-state trace boundary must preserve manual-waiver traces."),
		Boundary.TraceIds.Contains(TEXT("ongoing-trace/manual-waiver-trace"))
	);
	TestTrue(
		TEXT("The validation ongoing-state trace boundary must preserve the bounded ongoing-state trace surface."),
		Boundary.TraceSurfaceTags.Contains(TEXT("bounded ongoing-state trace"))
	);
	TestTrue(
		TEXT("The validation ongoing-state trace boundary must preserve the no-generic-ongoing-trace-platform guard."),
		Boundary.TraceGuardTags.Contains(TEXT("no-generic-ongoing-trace-platform guard"))
	);
	TestTrue(
		TEXT("The validation ongoing-state trace boundary must keep generic ongoing trace platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing trace platform ownership"))
	);
	return true;
}

#endif
