// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJVRootedStateLedgerContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJV.RootedStateLedgers",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJVRootedStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationRootedStateLedgerContract Contract;
	TestTrue(
		TEXT("The validation rooted-state ledger contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationRootedStateLedgerContract(
			TEXT("validation-rooted-state-ledger-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The validation rooted-state ledger contract id must stay stable."),
		Contract.ContractId,
		TEXT("validation-rooted-state-ledger-contract")
	);
	TestTrue(
		TEXT("The validation rooted-state ledger contract must preserve continuity-context rooted entries."),
		Contract.LedgerEntryIds.Contains(TEXT("rooted-state-ledger/continuity-context-rooted"))
	);
	TestTrue(
		TEXT("The validation rooted-state ledger contract must preserve the bounded rooted-state ledger surface."),
		Contract.LedgerSurfaceTags.Contains(TEXT("bounded rooted-state ledger"))
	);
	TestTrue(
		TEXT("The validation rooted-state ledger contract must preserve the no-generic-rooted-state-platform guard."),
		Contract.RootedGuardTags.Contains(TEXT("no-generic-rooted-state-platform guard"))
	);
	TestTrue(
		TEXT("The validation rooted-state ledger contract must keep generic rooted-state platform ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic rooted-state platform ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJVOngoingStateRatificationBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJV.OngoingStateRatifications",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJVOngoingStateRatificationBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateRatificationBoundary Boundary;
	TestTrue(
		TEXT("The validation ongoing-state ratification boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateRatificationBoundary(
			TEXT("validation-ongoing-state-ratification-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The validation ongoing-state ratification boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-ongoing-state-ratification-boundary")
	);
	TestTrue(
		TEXT("The validation ongoing-state ratification boundary must preserve benchmark-drift ratifications."),
		Boundary.RatificationIds.Contains(TEXT("ongoing-ratification/benchmark-drift-ratified"))
	);
	TestTrue(
		TEXT("The validation ongoing-state ratification boundary must preserve the bounded ongoing-state ratification surface."),
		Boundary.RatificationSurfaceTags.Contains(TEXT("bounded ongoing-state ratification"))
	);
	TestTrue(
		TEXT("The validation ongoing-state ratification boundary must preserve the no-generic-ongoing-ratification-platform guard."),
		Boundary.RatificationGuardTags.Contains(TEXT("no-generic-ongoing-ratification-platform guard"))
	);
	TestTrue(
		TEXT("The validation ongoing-state ratification boundary must keep generic ongoing ratification platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing ratification platform ownership"))
	);
	return true;
}

#endif
