#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBQTurretStatePacketContractTest,
	"HyperTwist.Validation.PhaseJBQ.TurretStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBQTurretStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationTurretStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationTurretStatePacketContract(
		TEXT("validation-turret-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBQOngoingStateAddendumBoundaryTest,
	"HyperTwist.Validation.PhaseJBQ.OngoingStateAddendumBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBQOngoingStateAddendumBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateAddendumBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateAddendumBoundary(
		TEXT("validation-ongoing-state-addendum-boundary"),
		Boundary);

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

	TestEqual(
		TEXT("The validation ongoing-state addendum boundary id must stay stable."),
		Boundary.BoundaryId,
		FString(TEXT("validation-ongoing-state-addendum-boundary")));
	TestTrue(
		TEXT("The validation ongoing-state addendum boundary must preserve manual-waiver addenda."),
		Boundary.AddendumIds.Contains(TEXT("ongoing-addendum/manual-waiver-addendum")));
	TestTrue(
		TEXT("The validation ongoing-state addendum boundary must preserve the bounded ongoing-state addendum surface."),
		Boundary.AddendumSurfaceTags.Contains(TEXT("bounded ongoing-state addendum")));
	TestTrue(
		TEXT("The validation ongoing-state addendum boundary must preserve the no-generic-ongoing-addendum-platform guard."),
		Boundary.AddendumGuardTags.Contains(TEXT("no-generic-ongoing-addendum-platform guard")));
	TestTrue(
		TEXT("The validation ongoing-state addendum boundary must keep generic ongoing addendum platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing addendum platform ownership")));

	return true;
}
