// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJWEmbeddedStatePacketContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJW.EmbeddedStatePackets",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJWEmbeddedStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationEmbeddedStatePacketContract Contract;
	TestTrue(
		TEXT("The validation embedded-state packet contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationEmbeddedStatePacketContract(
			TEXT("validation-embedded-state-packet-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The validation embedded-state packet contract id must stay stable."),
		Contract.ContractId,
		TEXT("validation-embedded-state-packet-contract")
	);
	TestTrue(
		TEXT("The validation embedded-state packet contract must preserve manual-waiver embedded packets."),
		Contract.PacketIds.Contains(TEXT("embedded-state-packet/manual-waiver-embedded"))
	);
	TestTrue(
		TEXT("The validation embedded-state packet contract must preserve the bounded embedded-state packet surface."),
		Contract.PacketSurfaceTags.Contains(TEXT("bounded embedded-state packet"))
	);
	TestTrue(
		TEXT("The validation embedded-state packet contract must preserve the no-generic-embedded-state-platform guard."),
		Contract.EmbeddedGuardTags.Contains(TEXT("no-generic-embedded-state-platform guard"))
	);
	TestTrue(
		TEXT("The validation embedded-state packet contract must keep generic embedded-state platform ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic embedded-state platform ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJWOngoingStateReconciliationBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJW.OngoingStateReconciliations",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJWOngoingStateReconciliationBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateReconciliationBoundary Boundary;
	TestTrue(
		TEXT("The validation ongoing-state reconciliation boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateReconciliationBoundary(
			TEXT("validation-ongoing-state-reconciliation-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The validation ongoing-state reconciliation boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-ongoing-state-reconciliation-boundary")
	);
	TestTrue(
		TEXT("The validation ongoing-state reconciliation boundary must preserve continuity-context reconciliations."),
		Boundary.ReconciliationIds.Contains(TEXT("ongoing-reconciliation/continuity-context-reconciled"))
	);
	TestTrue(
		TEXT("The validation ongoing-state reconciliation boundary must preserve the bounded ongoing-state reconciliation surface."),
		Boundary.ReconciliationSurfaceTags.Contains(TEXT("bounded ongoing-state reconciliation"))
	);
	TestTrue(
		TEXT("The validation ongoing-state reconciliation boundary must preserve the no-generic-ongoing-reconciliation-platform guard."),
		Boundary.ReconciliationGuardTags.Contains(TEXT("no-generic-ongoing-reconciliation-platform guard"))
	);
	TestTrue(
		TEXT("The validation ongoing-state reconciliation boundary must keep generic ongoing reconciliation platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing reconciliation platform ownership"))
	);
	return true;
}

#endif
