#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFAFrontalStatePacketContractTest,
	"HyperTwist.Validation.PhaseJFA.FrontalStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFAFrontalStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationFrontalStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationFrontalStatePacketContract(
		TEXT("validation-frontal-state-packet-contract"),
		Contract);

	TestTrue(
		TEXT("The validation frontal-state packet contract must resolve from the runtime library."),
		bResolved);
	if (!bResolved)
	{
		return false;
	}

	TestEqual(
		TEXT("The validation frontal-state packet contract id must stay stable."),
		Contract.ContractId,
		FString(TEXT("validation-frontal-state-packet-contract")));
	TestTrue(
		TEXT("The validation frontal-state packet contract must preserve benchmark-drift frontal packets."),
		Contract.PacketIds.Contains(TEXT("frontal-state-packet/benchmark-drift-frontal")));
	TestTrue(
		TEXT("The validation frontal-state packet contract must preserve the bounded frontal-state packet surface."),
		Contract.PacketSurfaceTags.Contains(TEXT("bounded frontal-state packet")));
	TestTrue(
		TEXT("The validation frontal-state packet contract must preserve the no-generic-frontal-state-platform guard."),
		Contract.FrontalGuardTags.Contains(TEXT("no-generic-frontal-state-platform guard")));
	TestTrue(
		TEXT("The validation frontal-state packet contract must keep generic frontal-state platform ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic frontal-state platform ownership")));

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFAOngoingStateAntependiumBoundaryTest,
	"HyperTwist.Validation.PhaseJFA.OngoingStateAntependiumBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFAOngoingStateAntependiumBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateAntependiumBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateAntependiumBoundary(
		TEXT("validation-ongoing-state-antependium-boundary"),
		Boundary);

	TestTrue(
		TEXT("The validation ongoing-state antependium boundary must resolve from the runtime library."),
		bResolved);
	if (!bResolved)
	{
		return false;
	}

	TestEqual(
		TEXT("The validation ongoing-state antependium boundary id must stay stable."),
		Boundary.BoundaryId,
		FString(TEXT("validation-ongoing-state-antependium-boundary")));
	TestTrue(
		TEXT("The validation ongoing-state antependium boundary must preserve manual-waiver antependium anchors."),
		Boundary.AntependiumIds.Contains(TEXT("ongoing-antependium/manual-waiver-antependium")));
	TestTrue(
		TEXT("The validation ongoing-state antependium boundary must preserve the bounded ongoing-state antependium surface."),
		Boundary.AntependiumSurfaceTags.Contains(TEXT("bounded ongoing-state antependium")));
	TestTrue(
		TEXT("The validation ongoing-state antependium boundary must preserve the no-generic-ongoing-antependium-platform guard."),
		Boundary.AntependiumGuardTags.Contains(TEXT("no-generic-ongoing-antependium-platform guard")));
	TestTrue(
		TEXT("The validation ongoing-state antependium boundary must keep generic ongoing antependium platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing antependium platform ownership")));

	return true;
}
