# Tests res://scripts/occlusion_policy.gd (NEO-17 occlusion config).
extends GdUnitTestSuite

const OcclusionPolicyScript := preload("res://scripts/occlusion_policy.gd")


func test_defaults_are_valid() -> void:
	# Arrange
	var p = OcclusionPolicyScript.new()
	# Act
	var ok: bool = p.is_valid()
	# Assert
	assert_that(ok).is_true()


func test_defaults_match_spec() -> void:
	# Arrange
	var p = OcclusionPolicyScript.new()
	# Act
	var enabled: bool = p.enabled
	var fade: float = p.fade_alpha
	var group: String = p.occluder_group
	var mask: int = p.occluder_collision_mask
	var depth: int = p.max_occluder_cast_depth
	var threshold: int = p.occluder_count_log_threshold
	# Assert
	assert_that(enabled).is_true()
	assert_that(fade).is_equal(0.25)
	assert_that(group).is_equal("occluder")
	assert_that(mask).is_equal(1)
	assert_that(depth).is_equal(4)
	assert_that(threshold).is_equal(0)


func test_is_valid_false_when_disabled() -> void:
	# Arrange
	var p = OcclusionPolicyScript.new()
	p.enabled = false
	# Act
	var ok: bool = p.is_valid()
	# Assert
	assert_that(ok).is_false()


func test_is_valid_true_when_fade_alpha_zero() -> void:
	# Arrange
	var p = OcclusionPolicyScript.new()
	p.fade_alpha = 0.0
	# Act
	var ok: bool = p.is_valid()
	# Assert
	assert_that(ok).is_true()


func test_is_valid_false_when_fade_alpha_negative() -> void:
	# Arrange
	var p = OcclusionPolicyScript.new()
	p.fade_alpha = -0.1
	# Act
	var ok: bool = p.is_valid()
	# Assert
	assert_that(ok).is_false()


func test_is_valid_true_at_full_opaque() -> void:
	# Arrange
	var p = OcclusionPolicyScript.new()
	p.fade_alpha = 1.0
	# Act
	var ok: bool = p.is_valid()
	# Assert
	assert_that(ok).is_true()
