diff --git a/tests/AcDream.Core.Tests/Rendering/RenderingDiagnosticsTests.cs b/tests/AcDream.Core.Tests/Rendering/RenderingDiagnosticsTests.cs new file mode 100644 index 0000000..8d020e5 --- /dev/null +++ b/tests/AcDream.Core.Tests/Rendering/RenderingDiagnosticsTests.cs @@ -0,0 +1,62 @@ +using AcDream.Core.Rendering; +using Xunit; + +namespace AcDream.Core.Tests.Rendering; + +public sealed class RenderingDiagnosticsTests +{ + [Fact] + public void IndoorAll_True_TurnsAllFlagsOn() + { + // Reset all flags off first to make the test deterministic + // regardless of env-var state on the test runner. + RenderingDiagnostics.ProbeIndoorWalkEnabled = false; + RenderingDiagnostics.ProbeIndoorLookupEnabled = false; + RenderingDiagnostics.ProbeIndoorUploadEnabled = false; + RenderingDiagnostics.ProbeIndoorXformEnabled = false; + RenderingDiagnostics.ProbeIndoorCullEnabled = false; + + RenderingDiagnostics.IndoorAll = true; + + Assert.True(RenderingDiagnostics.ProbeIndoorWalkEnabled); + Assert.True(RenderingDiagnostics.ProbeIndoorLookupEnabled); + Assert.True(RenderingDiagnostics.ProbeIndoorUploadEnabled); + Assert.True(RenderingDiagnostics.ProbeIndoorXformEnabled); + Assert.True(RenderingDiagnostics.ProbeIndoorCullEnabled); + Assert.True(RenderingDiagnostics.IndoorAll); + } + + [Fact] + public void IndoorAll_False_TurnsAllFlagsOff() + { + RenderingDiagnostics.IndoorAll = true; // start from all-on + RenderingDiagnostics.IndoorAll = false; + + Assert.False(RenderingDiagnostics.ProbeIndoorWalkEnabled); + Assert.False(RenderingDiagnostics.ProbeIndoorLookupEnabled); + Assert.False(RenderingDiagnostics.ProbeIndoorUploadEnabled); + Assert.False(RenderingDiagnostics.ProbeIndoorXformEnabled); + Assert.False(RenderingDiagnostics.ProbeIndoorCullEnabled); + Assert.False(RenderingDiagnostics.IndoorAll); + } + + [Fact] + public void IndoorAll_OneOff_ReadsAsFalse() + { + RenderingDiagnostics.IndoorAll = true; + RenderingDiagnostics.ProbeIndoorCullEnabled = false; // flip one off + Assert.False(RenderingDiagnostics.IndoorAll); + } + + [Theory] + [InlineData(0x00000029ul, false)] // outdoor cell 0x29 in 8x8 grid + [InlineData(0xA9B40029ul, false)] // outdoor cell with landblock prefix + [InlineData(0x00000100ul, true)] // indoor cell minimum + [InlineData(0x00000105ul, true)] // typical Holtburg Inn interior + [InlineData(0xA9B40105ul, true)] // indoor with landblock prefix + [InlineData(0xA9B401FFul, true)] // indoor near top of range + public void IsEnvCellId_DistinguishesOutdoorVsIndoorByLow16Bits(ulong id, bool expected) + { + Assert.Equal(expected, RenderingDiagnostics.IsEnvCellId(id)); + } +}