#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEWAltarStatePacketContractTest,
	"HyperTwist.Validation.PhaseJEW.AltarStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEWAltarStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationAltarStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationAltarStatePacketContract(
		TEXT("validation-altar-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEWOngoingStateReredosBoundaryTest,
	"HyperTwist.Validation.PhaseJEW.OngoingStateReredosBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEWOngoingStateReredosBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateReredosBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateReredosBoundary(
		TEXT("validation-ongoing-state-reredos-boundary"),
		Boundary);

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

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

	return true;
}
