#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCCVaultStatePacketContractTest,
	"HyperTwist.Validation.PhaseJCC.VaultStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCCVaultStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationVaultStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationVaultStatePacketContract(
		TEXT("validation-vault-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJCCOngoingStateApplauseBoundaryTest,
	"HyperTwist.Validation.PhaseJCC.OngoingStateApplauseBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJCCOngoingStateApplauseBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateApplauseBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateApplauseBoundary(
		TEXT("validation-ongoing-state-applause-boundary"),
		Boundary);

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

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

	return true;
}
