#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFKPiscinaStatePacketContractTest,
	"HyperTwist.Validation.PhaseJFK.PiscinaStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFKPiscinaStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationPiscinaStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationPiscinaStatePacketContract(
		TEXT("validation-piscina-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFKOngoingStateCredenceBoundaryTest,
	"HyperTwist.Validation.PhaseJFK.OngoingStateCredenceBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFKOngoingStateCredenceBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateCredenceBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateCredenceBoundary(
		TEXT("validation-ongoing-state-credence-boundary"),
		Boundary);

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

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

	return true;
}
