#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJESPewStatePacketContractTest,
	"HyperTwist.Validation.PhaseJES.PewStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJESPewStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationPewStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationPewStatePacketContract(
		TEXT("validation-pew-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJESOngoingStatePresbyteryBoundaryTest,
	"HyperTwist.Validation.PhaseJES.OngoingStatePresbyteryBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJESOngoingStatePresbyteryBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStatePresbyteryBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStatePresbyteryBoundary(
		TEXT("validation-ongoing-state-presbytery-boundary"),
		Boundary);

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

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

	return true;
}
