// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBLMerlonStateLedgerContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJBL.MerlonStateLedgers",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBLMerlonStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationMerlonStateLedgerContract Contract;
	TestTrue(
		TEXT("The validation merlon-state ledger contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationMerlonStateLedgerContract(
			TEXT("validation-merlon-state-ledger-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The validation merlon-state ledger contract id must stay stable."),
		Contract.ContractId,
		TEXT("validation-merlon-state-ledger-contract")
	);
	TestTrue(
		TEXT("The validation merlon-state ledger contract must preserve benchmark-drift merlon ledgers."),
		Contract.LedgerIds.Contains(TEXT("merlon-state-ledger/benchmark-drift-merlon"))
	);
	TestTrue(
		TEXT("The validation merlon-state ledger contract must preserve the bounded merlon-state ledger surface."),
		Contract.LedgerSurfaceTags.Contains(TEXT("bounded merlon-state ledger"))
	);
	TestTrue(
		TEXT("The validation merlon-state ledger contract must preserve the no-generic-merlon-state-platform guard."),
		Contract.MerlonGuardTags.Contains(TEXT("no-generic-merlon-state-platform guard"))
	);
	TestTrue(
		TEXT("The validation merlon-state ledger contract must keep generic merlon-state platform ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic merlon-state platform ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBLOngoingStateCalloutBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJBL.OngoingStateCallouts",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBLOngoingStateCalloutBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateCalloutBoundary Boundary;
	TestTrue(
		TEXT("The validation ongoing-state callout boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateCalloutBoundary(
			TEXT("validation-ongoing-state-callout-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The validation ongoing-state callout boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-ongoing-state-callout-boundary")
	);
	TestTrue(
		TEXT("The validation ongoing-state callout boundary must preserve manual-waiver callouts."),
		Boundary.CalloutIds.Contains(TEXT("ongoing-callout/manual-waiver-callout"))
	);
	TestTrue(
		TEXT("The validation ongoing-state callout boundary must preserve the bounded ongoing-state callout surface."),
		Boundary.CalloutSurfaceTags.Contains(TEXT("bounded ongoing-state callout"))
	);
	TestTrue(
		TEXT("The validation ongoing-state callout boundary must preserve the no-generic-ongoing-callout-platform guard."),
		Boundary.CalloutGuardTags.Contains(TEXT("no-generic-ongoing-callout-platform guard"))
	);
	TestTrue(
		TEXT("The validation ongoing-state callout boundary must keep generic ongoing callout platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing callout platform ownership"))
	);
	return true;
}

#endif
