#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBYAqueductStatePacketContractTest,
	"HyperTwist.Validation.PhaseJBY.AqueductStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBYAqueductStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationAqueductStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationAqueductStatePacketContract(
		TEXT("validation-aqueduct-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBYOngoingStateFinaleBoundaryTest,
	"HyperTwist.Validation.PhaseJBY.OngoingStateFinaleBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBYOngoingStateFinaleBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateFinaleBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateFinaleBoundary(
		TEXT("validation-ongoing-state-finale-boundary"),
		Boundary);

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

	TestEqual(
		TEXT("The validation ongoing-state finale boundary id must stay stable."),
		Boundary.BoundaryId,
		FString(TEXT("validation-ongoing-state-finale-boundary")));
	TestTrue(
		TEXT("The validation ongoing-state finale boundary must preserve manual-waiver finales."),
		Boundary.FinaleIds.Contains(TEXT("ongoing-finale/manual-waiver-finale")));
	TestTrue(
		TEXT("The validation ongoing-state finale boundary must preserve the bounded ongoing-state finale surface."),
		Boundary.FinaleSurfaceTags.Contains(TEXT("bounded ongoing-state finale")));
	TestTrue(
		TEXT("The validation ongoing-state finale boundary must preserve the no-generic-ongoing-finale-platform guard."),
		Boundary.FinaleGuardTags.Contains(TEXT("no-generic-ongoing-finale-platform guard")));
	TestTrue(
		TEXT("The validation ongoing-state finale boundary must keep generic ongoing finale platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing finale platform ownership")));

	return true;
}
