// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJABAggregatedStateLedgerContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJAB.AggregatedStateLedgers",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJABAggregatedStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationAggregatedStateLedgerContract Contract;
	TestTrue(
		TEXT("The validation aggregated-state ledger contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationAggregatedStateLedgerContract(
			TEXT("validation-aggregated-state-ledger-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The validation aggregated-state ledger contract id must stay stable."),
		Contract.ContractId,
		TEXT("validation-aggregated-state-ledger-contract")
	);
	TestTrue(
		TEXT("The validation aggregated-state ledger contract must preserve benchmark-drift aggregated entries."),
		Contract.LedgerEntryIds.Contains(TEXT("aggregated-state-ledger/benchmark-drift-aggregated"))
	);
	TestTrue(
		TEXT("The validation aggregated-state ledger contract must preserve the bounded aggregated-state ledger surface."),
		Contract.LedgerSurfaceTags.Contains(TEXT("bounded aggregated-state ledger"))
	);
	TestTrue(
		TEXT("The validation aggregated-state ledger contract must preserve the no-generic-aggregated-state-platform guard."),
		Contract.AggregatedGuardTags.Contains(TEXT("no-generic-aggregated-state-platform guard"))
	);
	TestTrue(
		TEXT("The validation aggregated-state ledger contract must keep generic aggregated-state platform ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic aggregated-state platform ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJABOngoingStateConsolidationBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJAB.OngoingStateConsolidations",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJABOngoingStateConsolidationBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateConsolidationBoundary Boundary;
	TestTrue(
		TEXT("The validation ongoing-state consolidation boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateConsolidationBoundary(
			TEXT("validation-ongoing-state-consolidation-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The validation ongoing-state consolidation boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-ongoing-state-consolidation-boundary")
	);
	TestTrue(
		TEXT("The validation ongoing-state consolidation boundary must preserve manual-waiver consolidations."),
		Boundary.ConsolidationIds.Contains(TEXT("ongoing-consolidation/manual-waiver-consolidated"))
	);
	TestTrue(
		TEXT("The validation ongoing-state consolidation boundary must preserve the bounded ongoing-state consolidation surface."),
		Boundary.ConsolidationSurfaceTags.Contains(TEXT("bounded ongoing-state consolidation"))
	);
	TestTrue(
		TEXT("The validation ongoing-state consolidation boundary must preserve the no-generic-ongoing-consolidation-platform guard."),
		Boundary.ConsolidationGuardTags.Contains(TEXT("no-generic-ongoing-consolidation-platform guard"))
	);
	TestTrue(
		TEXT("The validation ongoing-state consolidation boundary must keep generic ongoing consolidation platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing consolidation platform ownership"))
	);
	return true;
}

#endif
