#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBSGatehouseStatePacketContractTest,
	"HyperTwist.Validation.PhaseJBS.GatehouseStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBSGatehouseStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationGatehouseStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationGatehouseStatePacketContract(
		TEXT("validation-gatehouse-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBSOngoingStateCodicilBoundaryTest,
	"HyperTwist.Validation.PhaseJBS.OngoingStateCodicilBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBSOngoingStateCodicilBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateCodicilBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateCodicilBoundary(
		TEXT("validation-ongoing-state-codicil-boundary"),
		Boundary);

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

	TestEqual(
		TEXT("The validation ongoing-state codicil boundary id must stay stable."),
		Boundary.BoundaryId,
		FString(TEXT("validation-ongoing-state-codicil-boundary")));
	TestTrue(
		TEXT("The validation ongoing-state codicil boundary must preserve manual-waiver codicils."),
		Boundary.CodicilIds.Contains(TEXT("ongoing-codicil/manual-waiver-codicil")));
	TestTrue(
		TEXT("The validation ongoing-state codicil boundary must preserve the bounded ongoing-state codicil surface."),
		Boundary.CodicilSurfaceTags.Contains(TEXT("bounded ongoing-state codicil")));
	TestTrue(
		TEXT("The validation ongoing-state codicil boundary must preserve the no-generic-ongoing-codicil-platform guard."),
		Boundary.CodicilGuardTags.Contains(TEXT("no-generic-ongoing-codicil-platform guard")));
	TestTrue(
		TEXT("The validation ongoing-state codicil boundary must keep generic ongoing codicil platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing codicil platform ownership")));

	return true;
}
