#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEABaseStatePacketContractTest,
	"HyperTwist.Validation.PhaseJEA.BaseStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEABaseStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationBaseStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationBaseStatePacketContract(
		TEXT("validation-base-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEAOngoingStateUnionBoundaryTest,
	"HyperTwist.Validation.PhaseJEA.OngoingStateUnionBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEAOngoingStateUnionBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateUnionBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateUnionBoundary(
		TEXT("validation-ongoing-state-union-boundary"),
		Boundary);

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

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

	return true;
}
