#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBWCausewayStatePacketContractTest,
	"HyperTwist.Validation.PhaseJBW.CausewayStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBWCausewayStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationCausewayStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationCausewayStatePacketContract(
		TEXT("validation-causeway-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBWOngoingStateCodaBoundaryTest,
	"HyperTwist.Validation.PhaseJBW.OngoingStateCodaBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBWOngoingStateCodaBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateCodaBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateCodaBoundary(
		TEXT("validation-ongoing-state-coda-boundary"),
		Boundary);

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

	TestEqual(
		TEXT("The validation ongoing-state coda boundary id must stay stable."),
		Boundary.BoundaryId,
		FString(TEXT("validation-ongoing-state-coda-boundary")));
	TestTrue(
		TEXT("The validation ongoing-state coda boundary must preserve manual-waiver codas."),
		Boundary.CodaIds.Contains(TEXT("ongoing-coda/manual-waiver-coda")));
	TestTrue(
		TEXT("The validation ongoing-state coda boundary must preserve the bounded ongoing-state coda surface."),
		Boundary.CodaSurfaceTags.Contains(TEXT("bounded ongoing-state coda")));
	TestTrue(
		TEXT("The validation ongoing-state coda boundary must preserve the no-generic-ongoing-coda-platform guard."),
		Boundary.CodaGuardTags.Contains(TEXT("no-generic-ongoing-coda-platform guard")));
	TestTrue(
		TEXT("The validation ongoing-state coda boundary must keep generic ongoing coda platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing coda platform ownership")));

	return true;
}
