#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCWSimaStatePacketContractTest,
	"HyperTwist.Validation.PhaseJCW.SimaStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCWSimaStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationSimaStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationSimaStatePacketContract(
		TEXT("validation-sima-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCWOngoingStateDevotionBoundaryTest,
	"HyperTwist.Validation.PhaseJCW.OngoingStateDevotionBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCWOngoingStateDevotionBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateDevotionBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateDevotionBoundary(
		TEXT("validation-ongoing-state-devotion-boundary"),
		Boundary);

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

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

	return true;
}
