#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBUDrawbridgeStatePacketContractTest,
	"HyperTwist.Validation.PhaseJBU.DrawbridgeStatePacketContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBUDrawbridgeStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationDrawbridgeStatePacketContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationDrawbridgeStatePacketContract(
		TEXT("validation-drawbridge-state-packet-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBUOngoingStateAfterwordBoundaryTest,
	"HyperTwist.Validation.PhaseJBU.OngoingStateAfterwordBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBUOngoingStateAfterwordBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateAfterwordBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateAfterwordBoundary(
		TEXT("validation-ongoing-state-afterword-boundary"),
		Boundary);

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

	TestEqual(
		TEXT("The validation ongoing-state afterword boundary id must stay stable."),
		Boundary.BoundaryId,
		FString(TEXT("validation-ongoing-state-afterword-boundary")));
	TestTrue(
		TEXT("The validation ongoing-state afterword boundary must preserve manual-waiver afterwords."),
		Boundary.AfterwordIds.Contains(TEXT("ongoing-afterword/manual-waiver-afterword")));
	TestTrue(
		TEXT("The validation ongoing-state afterword boundary must preserve the bounded ongoing-state afterword surface."),
		Boundary.AfterwordSurfaceTags.Contains(TEXT("bounded ongoing-state afterword")));
	TestTrue(
		TEXT("The validation ongoing-state afterword boundary must preserve the no-generic-ongoing-afterword-platform guard."),
		Boundary.AfterwordGuardTags.Contains(TEXT("no-generic-ongoing-afterword-platform guard")));
	TestTrue(
		TEXT("The validation ongoing-state afterword boundary must keep generic ongoing afterword platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing afterword platform ownership")));

	return true;
}
