// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJAKLoopedStatePacketContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJAK.LoopedStatePackets",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

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

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJAKOngoingStateRefrainBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJAK.OngoingStateRefrains",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJAKOngoingStateRefrainBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateRefrainBoundary Boundary;
	TestTrue(
		TEXT("The validation ongoing-state refrain boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateRefrainBoundary(
			TEXT("validation-ongoing-state-refrain-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The validation ongoing-state refrain boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-ongoing-state-refrain-boundary")
	);
	TestTrue(
		TEXT("The validation ongoing-state refrain boundary must preserve manual-waiver refrains."),
		Boundary.RefrainIds.Contains(TEXT("ongoing-refrain/manual-waiver-refrained"))
	);
	TestTrue(
		TEXT("The validation ongoing-state refrain boundary must preserve the bounded ongoing-state refrain surface."),
		Boundary.RefrainSurfaceTags.Contains(TEXT("bounded ongoing-state refrain"))
	);
	TestTrue(
		TEXT("The validation ongoing-state refrain boundary must preserve the no-generic-ongoing-refrain-platform guard."),
		Boundary.RefrainGuardTags.Contains(TEXT("no-generic-ongoing-refrain-platform guard"))
	);
	TestTrue(
		TEXT("The validation ongoing-state refrain boundary must keep generic ongoing refrain platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing refrain platform ownership"))
	);
	return true;
}

#endif
