#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJGBCassockStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJGB.CassockStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJGBCassockStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationCassockStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationCassockStateLedgerContract(
		TEXT("validation-cassock-state-ledger-contract"),
		Contract);

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

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

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJGBOngoingStateRabatBoundaryTest,
	"HyperTwist.Validation.PhaseJGB.OngoingStateRabatBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJGBOngoingStateRabatBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateRabatBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateRabatBoundary(
		TEXT("validation-ongoing-state-rabat-boundary"),
		Boundary);

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

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

	return true;
}
