#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEQChoirStatePacketContractTest,
	"HyperTwist.Validation.PhaseJEQ.ChoirStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEQChoirStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationChoirStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationChoirStatePacketContract(
		TEXT("validation-choir-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEQOngoingStateVestryBoundaryTest,
	"HyperTwist.Validation.PhaseJEQ.OngoingStateVestryBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEQOngoingStateVestryBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateVestryBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateVestryBoundary(
		TEXT("validation-ongoing-state-vestry-boundary"),
		Boundary);

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

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

	return true;
}
