#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJECPedestalStatePacketContractTest,
	"HyperTwist.Validation.PhaseJEC.PedestalStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJECPedestalStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationPedestalStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationPedestalStatePacketContract(
		TEXT("validation-pedestal-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJECOngoingStatePartnershipBoundaryTest,
	"HyperTwist.Validation.PhaseJEC.OngoingStatePartnershipBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJECOngoingStatePartnershipBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStatePartnershipBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStatePartnershipBoundary(
		TEXT("validation-ongoing-state-partnership-boundary"),
		Boundary);

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

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

	return true;
}
