#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEMMinbarStatePacketContractTest,
	"HyperTwist.Validation.PhaseJEM.MinbarStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEMMinbarStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationMinbarStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationMinbarStatePacketContract(
		TEXT("validation-minbar-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEMOngoingStateConclaveBoundaryTest,
	"HyperTwist.Validation.PhaseJEM.OngoingStateConclaveBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEMOngoingStateConclaveBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateConclaveBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateConclaveBoundary(
		TEXT("validation-ongoing-state-conclave-boundary"),
		Boundary);

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

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

	return true;
}
