// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJAGInterlacedStatePacketContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJAG.InterlacedStatePackets",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

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

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJAGOngoingStateAffinityBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJAG.OngoingStateAffinities",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJAGOngoingStateAffinityBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateAffinityBoundary Boundary;
	TestTrue(
		TEXT("The validation ongoing-state affinity boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateAffinityBoundary(
			TEXT("validation-ongoing-state-affinity-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The validation ongoing-state affinity boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-ongoing-state-affinity-boundary")
	);
	TestTrue(
		TEXT("The validation ongoing-state affinity boundary must preserve manual-waiver affinities."),
		Boundary.AffinityIds.Contains(TEXT("ongoing-affinity/manual-waiver-affined"))
	);
	TestTrue(
		TEXT("The validation ongoing-state affinity boundary must preserve the bounded ongoing-state affinity surface."),
		Boundary.AffinitySurfaceTags.Contains(TEXT("bounded ongoing-state affinity"))
	);
	TestTrue(
		TEXT("The validation ongoing-state affinity boundary must preserve the no-generic-ongoing-affinity-platform guard."),
		Boundary.AffinityGuardTags.Contains(TEXT("no-generic-ongoing-affinity-platform guard"))
	);
	TestTrue(
		TEXT("The validation ongoing-state affinity boundary must keep generic ongoing affinity platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing affinity platform ownership"))
	);
	return true;
}

#endif
