#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDYTaperStatePacketContractTest,
	"HyperTwist.Validation.PhaseJDY.TaperStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDYTaperStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationTaperStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationTaperStatePacketContract(
		TEXT("validation-taper-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDYOngoingStateHarmonyBoundaryTest,
	"HyperTwist.Validation.PhaseJDY.OngoingStateHarmonyBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDYOngoingStateHarmonyBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateHarmonyBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateHarmonyBoundary(
		TEXT("validation-ongoing-state-harmony-boundary"),
		Boundary);

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

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

	return true;
}
