// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJPPersistentStateLedgerContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJP.PersistentStateLedgers",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

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

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJPOngoingStateAcknowledgementBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJP.OngoingStateAcknowledgements",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJPOngoingStateAcknowledgementBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateAcknowledgementBoundary Boundary;
	TestTrue(
		TEXT("The validation ongoing-state acknowledgement boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateAcknowledgementBoundary(
			TEXT("validation-ongoing-state-acknowledgement-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The validation ongoing-state acknowledgement boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-ongoing-state-acknowledgement-boundary")
	);
	TestTrue(
		TEXT("The validation ongoing-state acknowledgement boundary must preserve manual-waiver acknowledgements."),
		Boundary.AcknowledgementIds.Contains(TEXT("ongoing-acknowledgement/manual-waiver-acknowledged"))
	);
	TestTrue(
		TEXT("The validation ongoing-state acknowledgement boundary must preserve the bounded ongoing-state acknowledgement surface."),
		Boundary.AcknowledgementSurfaceTags.Contains(TEXT("bounded ongoing-state acknowledgement"))
	);
	TestTrue(
		TEXT("The validation ongoing-state acknowledgement boundary must preserve the no-generic-ongoing-acknowledgement-platform guard."),
		Boundary.AcknowledgementGuardTags.Contains(TEXT("no-generic-ongoing-acknowledgement-platform guard"))
	);
	TestTrue(
		TEXT("The validation ongoing-state acknowledgement boundary must keep generic ongoing acknowledgement platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing acknowledgement platform ownership"))
	);
	return true;
}

#endif
