#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBTPortcullisStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJBT.PortcullisStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBTPortcullisStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationPortcullisStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationPortcullisStateLedgerContract(
		TEXT("validation-portcullis-state-ledger-contract"),
		Contract);

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

	TestEqual(
		TEXT("The validation portcullis-state ledger contract id must stay stable."),
		Contract.ContractId,
		FString(TEXT("validation-portcullis-state-ledger-contract")));
	TestTrue(
		TEXT("The validation portcullis-state ledger contract must preserve benchmark-drift portcullis ledgers."),
		Contract.LedgerIds.Contains(TEXT("portcullis-state-ledger/benchmark-drift-portcullis")));
	TestTrue(
		TEXT("The validation portcullis-state ledger contract must preserve the bounded portcullis-state ledger surface."),
		Contract.LedgerSurfaceTags.Contains(TEXT("bounded portcullis-state ledger")));
	TestTrue(
		TEXT("The validation portcullis-state ledger contract must preserve the no-generic-portcullis-state-platform guard."),
		Contract.PortcullisGuardTags.Contains(TEXT("no-generic-portcullis-state-platform guard")));
	TestTrue(
		TEXT("The validation portcullis-state ledger contract must keep generic portcullis-state platform ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic portcullis-state platform ownership")));

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBTOngoingStatePostscriptBoundaryTest,
	"HyperTwist.Validation.PhaseJBT.OngoingStatePostscriptBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBTOngoingStatePostscriptBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStatePostscriptBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStatePostscriptBoundary(
		TEXT("validation-ongoing-state-postscript-boundary"),
		Boundary);

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

	TestEqual(
		TEXT("The validation ongoing-state postscript boundary id must stay stable."),
		Boundary.BoundaryId,
		FString(TEXT("validation-ongoing-state-postscript-boundary")));
	TestTrue(
		TEXT("The validation ongoing-state postscript boundary must preserve manual-waiver postscripts."),
		Boundary.PostscriptIds.Contains(TEXT("ongoing-postscript/manual-waiver-postscript")));
	TestTrue(
		TEXT("The validation ongoing-state postscript boundary must preserve the bounded ongoing-state postscript surface."),
		Boundary.PostscriptSurfaceTags.Contains(TEXT("bounded ongoing-state postscript")));
	TestTrue(
		TEXT("The validation ongoing-state postscript boundary must preserve the no-generic-ongoing-postscript-platform guard."),
		Boundary.PostscriptGuardTags.Contains(TEXT("no-generic-ongoing-postscript-platform guard")));
	TestTrue(
		TEXT("The validation ongoing-state postscript boundary must keep generic ongoing postscript platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing postscript platform ownership")));

	return true;
}
