// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJARCreasedStateLedgerContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJAR.CreasedStateLedgers",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

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

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJAROngoingStateResidueBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJAR.OngoingStateResidues",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJAROngoingStateResidueBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateResidueBoundary Boundary;
	TestTrue(
		TEXT("The validation ongoing-state residue boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateResidueBoundary(
			TEXT("validation-ongoing-state-residue-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The validation ongoing-state residue boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-ongoing-state-residue-boundary")
	);
	TestTrue(
		TEXT("The validation ongoing-state residue boundary must preserve manual-waiver residues."),
		Boundary.ResidueIds.Contains(TEXT("ongoing-residue/manual-waiver-residual"))
	);
	TestTrue(
		TEXT("The validation ongoing-state residue boundary must preserve the bounded ongoing-state residue surface."),
		Boundary.ResidueSurfaceTags.Contains(TEXT("bounded ongoing-state residue"))
	);
	TestTrue(
		TEXT("The validation ongoing-state residue boundary must preserve the no-generic-ongoing-residue-platform guard."),
		Boundary.ResidueGuardTags.Contains(TEXT("no-generic-ongoing-residue-platform guard"))
	);
	TestTrue(
		TEXT("The validation ongoing-state residue boundary must keep generic ongoing residue platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing residue platform ownership"))
	);
	return true;
}

#endif
