#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCASpanStatePacketContractTest,
	"HyperTwist.Validation.PhaseJCA.SpanStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCASpanStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationSpanStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationSpanStatePacketContract(
		TEXT("validation-span-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCAOngoingStateBowBoundaryTest,
	"HyperTwist.Validation.PhaseJCA.OngoingStateBowBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCAOngoingStateBowBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateBowBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateBowBoundary(
		TEXT("validation-ongoing-state-bow-boundary"),
		Boundary);

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

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

	return true;
}
