#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#include "Misc/AutomationTest.h"

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBPBartizanStateLedgerContractTest,
	"HyperTwist.Validation.PhaseJBP.BartizanStateLedgerContract",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBPBartizanStateLedgerContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationBartizanStateLedgerContract Contract;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationBartizanStateLedgerContract(
		TEXT("validation-bartizan-state-ledger-contract"),
		Contract);

	TestTrue(
		TEXT("The validation bartizan-state ledger contract must resolve from the runtime library."),
		bResolved);
	if (!bResolved)
	{
		return false;
	}

	TestEqual(
		TEXT("The validation bartizan-state ledger contract id must stay stable."),
		Contract.ContractId,
		FString(TEXT("validation-bartizan-state-ledger-contract")));
	TestTrue(
		TEXT("The validation bartizan-state ledger contract must preserve benchmark-drift bartizan ledgers."),
		Contract.LedgerIds.Contains(TEXT("bartizan-state-ledger/benchmark-drift-bartizan")));
	TestTrue(
		TEXT("The validation bartizan-state ledger contract must preserve the bounded bartizan-state ledger surface."),
		Contract.LedgerSurfaceTags.Contains(TEXT("bounded bartizan-state ledger")));
	TestTrue(
		TEXT("The validation bartizan-state ledger contract must preserve the no-generic-bartizan-state-platform guard."),
		Contract.BartizanGuardTags.Contains(TEXT("no-generic-bartizan-state-platform guard")));
	TestTrue(
		TEXT("The validation bartizan-state ledger contract must keep generic bartizan-state platform ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic bartizan-state platform ownership")));

	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJBPOngoingStateEndnoteBoundaryTest,
	"HyperTwist.Validation.PhaseJBP.OngoingStateEndnoteBoundary",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJBPOngoingStateEndnoteBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateEndnoteBoundary Boundary;
	const bool bResolved = UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateEndnoteBoundary(
		TEXT("validation-ongoing-state-endnote-boundary"),
		Boundary);

	TestTrue(
		TEXT("The validation ongoing-state endnote boundary must resolve from the runtime library."),
		bResolved);
	if (!bResolved)
	{
		return false;
	}

	TestEqual(
		TEXT("The validation ongoing-state endnote boundary id must stay stable."),
		Boundary.BoundaryId,
		FString(TEXT("validation-ongoing-state-endnote-boundary")));
	TestTrue(
		TEXT("The validation ongoing-state endnote boundary must preserve manual-waiver endnotes."),
		Boundary.EndnoteIds.Contains(TEXT("ongoing-endnote/manual-waiver-endnote")));
	TestTrue(
		TEXT("The validation ongoing-state endnote boundary must preserve the bounded ongoing-state endnote surface."),
		Boundary.EndnoteSurfaceTags.Contains(TEXT("bounded ongoing-state endnote")));
	TestTrue(
		TEXT("The validation ongoing-state endnote boundary must preserve the no-generic-ongoing-endnote-platform guard."),
		Boundary.EndnoteGuardTags.Contains(TEXT("no-generic-ongoing-endnote-platform guard")));
	TestTrue(
		TEXT("The validation ongoing-state endnote boundary must keep generic ongoing endnote platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing endnote platform ownership")));

	return true;
}
