// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJUGroundedStatePacketContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJU.GroundedStatePackets",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJUGroundedStatePacketContractTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationGroundedStatePacketContract Contract;
	TestTrue(
		TEXT("The validation grounded-state packet contract must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationGroundedStatePacketContract(
			TEXT("validation-grounded-state-packet-contract"),
			Contract
		)
	);
	TestEqual(
		TEXT("The validation grounded-state packet contract id must stay stable."),
		Contract.ContractId,
		TEXT("validation-grounded-state-packet-contract")
	);
	TestTrue(
		TEXT("The validation grounded-state packet contract must preserve benchmark-drift grounded packets."),
		Contract.PacketIds.Contains(TEXT("grounded-state-packet/benchmark-drift-grounded"))
	);
	TestTrue(
		TEXT("The validation grounded-state packet contract must preserve the bounded grounded-state packet surface."),
		Contract.PacketSurfaceTags.Contains(TEXT("bounded grounded-state packet"))
	);
	TestTrue(
		TEXT("The validation grounded-state packet contract must preserve the no-generic-grounded-state-platform guard."),
		Contract.GroundedGuardTags.Contains(TEXT("no-generic-grounded-state-platform guard"))
	);
	TestTrue(
		TEXT("The validation grounded-state packet contract must keep generic grounded-state platform ownership excluded."),
		Contract.ExplicitExclusions.Contains(TEXT("generic grounded-state platform ownership"))
	);
	return true;
}

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJUOngoingStateEndorsementBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJU.OngoingStateEndorsements",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJUOngoingStateEndorsementBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateEndorsementBoundary Boundary;
	TestTrue(
		TEXT("The validation ongoing-state endorsement boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateEndorsementBoundary(
			TEXT("validation-ongoing-state-endorsement-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The validation ongoing-state endorsement boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-ongoing-state-endorsement-boundary")
	);
	TestTrue(
		TEXT("The validation ongoing-state endorsement boundary must preserve manual-waiver endorsements."),
		Boundary.EndorsementIds.Contains(TEXT("ongoing-endorsement/manual-waiver-endorsed"))
	);
	TestTrue(
		TEXT("The validation ongoing-state endorsement boundary must preserve the bounded ongoing-state endorsement surface."),
		Boundary.EndorsementSurfaceTags.Contains(TEXT("bounded ongoing-state endorsement"))
	);
	TestTrue(
		TEXT("The validation ongoing-state endorsement boundary must preserve the no-generic-ongoing-endorsement-platform guard."),
		Boundary.EndorsementGuardTags.Contains(TEXT("no-generic-ongoing-endorsement-platform guard"))
	);
	TestTrue(
		TEXT("The validation ongoing-state endorsement boundary must keep generic ongoing endorsement platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing endorsement platform ownership"))
	);
	return true;
}

#endif
