#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBRBarbicanStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJBR.BarbicanStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBRBarbicanStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationBarbicanStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationBarbicanStateLedgerContract(
		TEXT("validation-barbican-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBROngoingStateAppendixBoundaryTest,
	"HyperTwist.Validation.PhaseJBR.OngoingStateAppendixBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBROngoingStateAppendixBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateAppendixBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateAppendixBoundary(
		TEXT("validation-ongoing-state-appendix-boundary"),
		Boundary);

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

	TestEqual(
		TEXT("The validation ongoing-state appendix boundary id must stay stable."),
		Boundary.BoundaryId,
		FString(TEXT("validation-ongoing-state-appendix-boundary")));
	TestTrue(
		TEXT("The validation ongoing-state appendix boundary must preserve manual-waiver appendices."),
		Boundary.AppendixIds.Contains(TEXT("ongoing-appendix/manual-waiver-appendix")));
	TestTrue(
		TEXT("The validation ongoing-state appendix boundary must preserve the bounded ongoing-state appendix surface."),
		Boundary.AppendixSurfaceTags.Contains(TEXT("bounded ongoing-state appendix")));
	TestTrue(
		TEXT("The validation ongoing-state appendix boundary must preserve the no-generic-ongoing-appendix-platform guard."),
		Boundary.AppendixGuardTags.Contains(TEXT("no-generic-ongoing-appendix-platform guard")));
	TestTrue(
		TEXT("The validation ongoing-state appendix boundary must keep generic ongoing appendix platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing appendix platform ownership")));

	return true;
}
