// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistTraining/HyperTwistTrainingRuntimeLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJSSustainedStatePacketContractTest,
	"HyperTwist.FirstParty.Validation.PhaseJS.SustainedStatePackets",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

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

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistValidationPhaseJSOngoingStateAssuranceBoundaryTest,
	"HyperTwist.FirstParty.Validation.PhaseJS.OngoingStateAssurances",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistValidationPhaseJSOngoingStateAssuranceBoundaryTest::RunTest(const FString& Parameters)
{
	FHyperTwistTrainingValidationOngoingStateAssuranceBoundary Boundary;
	TestTrue(
		TEXT("The validation ongoing-state assurance boundary must resolve from the runtime library."),
		UHyperTwistTrainingRuntimeLibrary::TryGetBundledValidationOngoingStateAssuranceBoundary(
			TEXT("validation-ongoing-state-assurance-boundary"),
			Boundary
		)
	);
	TestEqual(
		TEXT("The validation ongoing-state assurance boundary id must stay stable."),
		Boundary.BoundaryId,
		TEXT("validation-ongoing-state-assurance-boundary")
	);
	TestTrue(
		TEXT("The validation ongoing-state assurance boundary must preserve manual-waiver assurances."),
		Boundary.AssuranceIds.Contains(TEXT("ongoing-assurance/manual-waiver-assured"))
	);
	TestTrue(
		TEXT("The validation ongoing-state assurance boundary must preserve the bounded ongoing-state assurance surface."),
		Boundary.AssuranceSurfaceTags.Contains(TEXT("bounded ongoing-state assurance"))
	);
	TestTrue(
		TEXT("The validation ongoing-state assurance boundary must preserve the no-generic-ongoing-assurance-platform guard."),
		Boundary.AssuranceGuardTags.Contains(TEXT("no-generic-ongoing-assurance-platform guard"))
	);
	TestTrue(
		TEXT("The validation ongoing-state assurance boundary must keep generic ongoing assurance platform ownership excluded."),
		Boundary.ExplicitExclusions.Contains(TEXT("generic ongoing assurance platform ownership"))
	);
	return true;
}

#endif
