#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEKPulpitStatePacketContractTest,
	"HyperTwist.Validation.PhaseJEK.PulpitStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEKPulpitStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationPulpitStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationPulpitStatePacketContract(
		TEXT("validation-pulpit-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEKOngoingStateCaucusBoundaryTest,
	"HyperTwist.Validation.PhaseJEK.OngoingStateCaucusBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEKOngoingStateCaucusBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateCaucusBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateCaucusBoundary(
		TEXT("validation-ongoing-state-caucus-boundary"),
		Boundary);

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

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

	return true;
}
