#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFOCustodiaStatePacketContractTest,
	"HyperTwist.Validation.PhaseJFO.CustodiaStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFOCustodiaStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationCustodiaStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationCustodiaStatePacketContract(
		TEXT("validation-custodia-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJFOOngoingStatePyxClothBoundaryTest,
	"HyperTwist.Validation.PhaseJFO.OngoingStatePyxClothBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJFOOngoingStatePyxClothBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStatePyxClothBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStatePyxClothBoundary(
		TEXT("validation-ongoing-state-pyx-cloth-boundary"),
		Boundary);

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

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

	return true;
}
