// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJGCarryForwardLedgerContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJG.CarryForwardLedgers",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJGCarryForwardLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationCarryForwardLedgerContract Contract;
	TestTrue(
		TEXT("The validation carry-forward ledger contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationCarryForwardLedgerContract(
			TEXT("validation-carry-forward-ledger-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The validation carry-forward ledger contract id must stay stable."),
		Contract.ContractId,
		TEXT("validation-carry-forward-ledger-contract")
	);
	TestTrue(
		TEXT("The validation carry-forward ledger contract must preserve benchmark-delta carry-forward entries."),
		Contract.LedgerEntryIds.Contains(TEXT("carry-forward-ledger/benchmark-delta-context"))
	);
	TestTrue(
		TEXT("The validation carry-forward ledger contract must preserve the bounded carry-forward ledger surface."),
		Contract.LedgerSurfaceTags.Contains(TEXT("bounded carry-forward ledger"))
	);
	TestTrue(
		TEXT("The validation carry-forward ledger contract must preserve the same-lane reviewer continuity guard."),
		Contract.ContinuityGuardTags.Contains(TEXT("same-lane reviewer continuity guard"))
	);
	TestTrue(
		TEXT("The validation carry-forward ledger contract must keep generic case-history ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic case-history ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJGReviewerContinuityDigestBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJG.ReviewerContinuityDigests",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJGReviewerContinuityDigestBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingReviewerContinuityDigestBoundary Boundary;
	TestTrue(
		TEXT("The reviewer continuity digest boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledReviewerContinuityDigestBoundary(
			TEXT("validation-reviewer-continuity-digest-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The reviewer continuity digest boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-reviewer-continuity-digest-boundary")
	);
	TestTrue(
		TEXT("The reviewer continuity digest boundary must preserve waiver-rationale continuity digests."),
		Boundary.DigestIds.Contains(TEXT("continuity-digest/waiver-rationale-context"))
	);
	TestTrue(
		TEXT("The reviewer continuity digest boundary must preserve the bounded reviewer continuity digest surface."),
		Boundary.DigestSurfaceTags.Contains(TEXT("bounded reviewer continuity digest"))
	);
	TestTrue(
		TEXT("The reviewer continuity digest boundary must preserve the no-knowledge-base ownership guard."),
		Boundary.HandoffGuardTags.Contains(TEXT("no-knowledge-base ownership guard"))
	);
	TestTrue(
		TEXT("The reviewer continuity digest boundary must keep generic knowledge base ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic knowledge base ownership"))
	);
	return true;
}

#endif
