// Copyright HyperTwist, Inc. All Rights Reserved.

#include "Misc/AutomationTest.h"

#include "HyperTwistSimulation/HyperTwistSimulationLibrary.h"

#if WITH_AUTOMATION_TESTS

IMPLEMENT_SIMPLE_AUTOMATION_TEST(
	FHyperTwistSimulationLibrarySceneContextSamplesTest,
	"HyperTwist.Simulation.SceneContext.SampleHelpers",
	EAutomationTestFlags::EditorContext | EAutomationTestFlags::EngineFilter
)

bool FHyperTwistSimulationLibrarySceneContextSamplesTest::RunTest(const FString& Parameters)
{
	const FHyperTwistSimulationSceneContext ClassicSample =
		UHyperTwistSimulationLibrary::MakeClassicSampleSceneContext();
	const FHyperTwistSimulationSceneContext ClassicLegacy =
		UHyperTwistSimulationLibrary::MakeClassicPlaceholderSceneContext();
	const FHyperTwistSimulationSceneContext HyperSample =
		UHyperTwistSimulationLibrary::MakeHyperSampleSceneContext();
	const FHyperTwistSimulationSceneContext HyperLegacy =
		UHyperTwistSimulationLibrary::MakeHyperPlaceholderSceneContext();

	TestTrue(
		TEXT("The classic sample scene-context helper must remain structurally valid."),
		ClassicSample.IsStructurallyValid()
	);
	TestTrue(
		TEXT("The hyper sample scene-context helper must remain structurally valid."),
		HyperSample.IsStructurallyValid()
	);
	TestFalse(
		TEXT("The classic sample scene-context id should no longer advertise placeholder product posture."),
		ClassicSample.SceneContextId.Contains(TEXT("placeholder"), ESearchCase::IgnoreCase)
	);
	TestFalse(
		TEXT("The hyper sample scene-context id should no longer advertise placeholder product posture."),
		HyperSample.SceneContextId.Contains(TEXT("placeholder"), ESearchCase::IgnoreCase)
	);
	TestFalse(
		TEXT("The classic sample render-state profile should no longer advertise placeholder posture."),
		ClassicSample.RenderStateProfile.Contains(TEXT("placeholder"), ESearchCase::IgnoreCase)
	);
	TestFalse(
		TEXT("The hyper sample render-state profile should no longer advertise placeholder posture."),
		HyperSample.RenderStateProfile.Contains(TEXT("placeholder"), ESearchCase::IgnoreCase)
	);
	TestFalse(
		TEXT("The classic sample projection profile should no longer advertise placeholder posture."),
		ClassicSample.ProjectionSettings.ProjectionProfile.Contains(TEXT("placeholder"), ESearchCase::IgnoreCase)
	);
	TestFalse(
		TEXT("The hyper sample projection profile should no longer advertise placeholder posture."),
		HyperSample.ProjectionSettings.ProjectionProfile.Contains(TEXT("placeholder"), ESearchCase::IgnoreCase)
	);
	TestEqual(
		TEXT("The deprecated classic placeholder helper must remain a compatibility wrapper over the renamed sample helper."),
		ClassicLegacy.SceneContextId,
		ClassicSample.SceneContextId
	);
	TestEqual(
		TEXT("The deprecated hyper placeholder helper must remain a compatibility wrapper over the renamed sample helper."),
		HyperLegacy.SceneContextId,
		HyperSample.SceneContextId
	);
	TestEqual(
		TEXT("The deprecated classic placeholder helper must preserve the sample render-state profile."),
		ClassicLegacy.RenderStateProfile,
		ClassicSample.RenderStateProfile
	);
	TestEqual(
		TEXT("The deprecated hyper placeholder helper must preserve the sample render-state profile."),
		HyperLegacy.RenderStateProfile,
		HyperSample.RenderStateProfile
	);
	TestEqual(
		TEXT("The deprecated classic placeholder helper must preserve the sample projection profile."),
		ClassicLegacy.ProjectionSettings.ProjectionProfile,
		ClassicSample.ProjectionSettings.ProjectionProfile
	);
	TestEqual(
		TEXT("The deprecated hyper placeholder helper must preserve the sample projection profile."),
		HyperLegacy.ProjectionSettings.ProjectionProfile,
		HyperSample.ProjectionSettings.ProjectionProfile
	);
	TestEqual(
		TEXT("The deprecated classic placeholder helper must preserve the sample projection depth."),
		ClassicLegacy.ProjectionSettings.ProjectionDepth,
		ClassicSample.ProjectionSettings.ProjectionDepth
	);
	TestEqual(
		TEXT("The deprecated hyper placeholder helper must preserve the sample projection depth."),
		HyperLegacy.ProjectionSettings.ProjectionDepth,
		HyperSample.ProjectionSettings.ProjectionDepth
	);

	return true;
}

#endif
