// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJREnduringStateLedgerContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJR.EnduringStateLedgers",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

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

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJROngoingStateCertificationBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJR.OngoingStateCertifications",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJROngoingStateCertificationBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateCertificationBoundary Boundary;
	TestTrue(
		TEXT("The validation ongoing-state certification boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateCertificationBoundary(
			TEXT("validation-ongoing-state-certification-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The validation ongoing-state certification boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-ongoing-state-certification-boundary")
	);
	TestTrue(
		TEXT("The validation ongoing-state certification boundary must preserve manual-waiver certifications."),
		Boundary.CertificationIds.Contains(TEXT("ongoing-certification/manual-waiver-certified"))
	);
	TestTrue(
		TEXT("The validation ongoing-state certification boundary must preserve the bounded ongoing-state certification surface."),
		Boundary.CertificationSurfaceTags.Contains(TEXT("bounded ongoing-state certification"))
	);
	TestTrue(
		TEXT("The validation ongoing-state certification boundary must preserve the no-generic-ongoing-certification-platform guard."),
		Boundary.CertificationGuardTags.Contains(TEXT("no-generic-ongoing-certification-platform guard"))
	);
	TestTrue(
		TEXT("The validation ongoing-state certification boundary must keep generic ongoing certification platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing certification platform ownership"))
	);
	return true;
}

#endif
