#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEOBemaStatePacketContractTest,
	"HyperTwist.Validation.PhaseJEO.BemaStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEOBemaStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationBemaStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationBemaStatePacketContract(
		TEXT("validation-bema-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEOOngoingStateConvocationBoundaryTest,
	"HyperTwist.Validation.PhaseJEO.OngoingStateConvocationBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEOOngoingStateConvocationBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateConvocationBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateConvocationBoundary(
		TEXT("validation-ongoing-state-convocation-boundary"),
		Boundary);

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

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

	return true;
}
