#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDQCymaRectaStatePacketContractTest,
	"HyperTwist.Validation.PhaseJDQ.CymaRectaStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDQCymaRectaStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationCymaRectaStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationCymaRectaStatePacketContract(
		TEXT("validation-cyma-recta-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJDQOngoingStateFellowshipBoundaryTest,
	"HyperTwist.Validation.PhaseJDQ.OngoingStateFellowshipBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJDQOngoingStateFellowshipBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateFellowshipBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateFellowshipBoundary(
		TEXT("validation-ongoing-state-fellowship-boundary"),
		Boundary);

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

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

	return true;
}
