#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEITribuneStatePacketContractTest,
	"HyperTwist.Validation.PhaseJEI.TribuneStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEITribuneStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationTribuneStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationTribuneStatePacketContract(
		TEXT("validation-tribune-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJEIOngoingStateForumBoundaryTest,
	"HyperTwist.Validation.PhaseJEI.OngoingStateForumBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJEIOngoingStateForumBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateForumBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateForumBoundary(
		TEXT("validation-ongoing-state-forum-boundary"),
		Boundary);

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

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

	return true;
}
