acdream/tests/AcDream.Core.Tests/Rendering/Wb/WbMeshAdapterTests.cs
Erik 3e6f6ec858 chore(O-T7): code-review housekeeping after WB extraction
Five small post-cleanup items from T7 code review:

I1: Removed dead `datDir` parameter from WbMeshAdapter ctor (parameter
    was unused after _wbDats removal; ArgumentNullException.ThrowIfNull
    was misleading). Updated call sites in GameWindow.cs and
    WbMeshAdapterTests.cs.

I2: Updated stale GameWindow.cs comment that still described
    WbMeshAdapter as opening its own dat handles. Now reflects Phase O
    state: shared DatCollection via DatCollectionAdapter.

I3: Documented thread-safety contract on RenderStateCache (render-thread
    only — required for the mutable-static GL sentinel pattern).

M1: Added comment on IDatReaderWriter's write-path methods noting they
    are preserved for verbatim compatibility but unused in acdream.

M3: Added comment on Chorizite.Core PackageReference in Core.csproj
    explaining the previously-transitive dependency.

Also excluded SplitFormulaDivergenceTest.cs from the test build via
<Compile Remove>: this N.5b one-time data-collection test referenced
WorldBuilder.Shared types directly; after Phase O-T7 dropped that
project reference it no longer compiles. The sweep data it produced
already informed the N.5b Path-C decision and the file is retained
in the tree for historical reference.

Build green; tests green (1146 + 8 pre-existing failures baseline
maintained).

Spec: docs/superpowers/specs/2026-05-21-phase-o-dat-path-unification-design.md

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-21 17:29:06 +02:00

65 lines
2 KiB
C#

using System;
using AcDream.App.Rendering.Wb;
using Microsoft.Extensions.Logging.Abstractions;
using Silk.NET.OpenGL;
namespace AcDream.Core.Tests.Rendering.Wb;
public sealed class WbMeshAdapterTests
{
[Fact]
public void Construct_WithNullGl_ThrowsArgumentNull()
{
// GL is the first guarded parameter; verifies the constructor validates inputs.
// We can't pass a real GL (no context in tests), so we verify only the
// null-GL guard. The real pipeline is tested via integration.
Assert.Throws<ArgumentNullException>(() =>
new WbMeshAdapter(gl: null!, dats: null!, logger: NullLogger<WbMeshAdapter>.Instance));
}
[Fact]
public void Dispose_OnUninitializedAdapter_DoesNotThrow()
{
var adapter = WbMeshAdapter.CreateUninitialized();
adapter.Dispose(); // no-op when fields are null
adapter.Dispose(); // idempotent
}
[Fact]
public void IncrementRefCount_OnUninitializedAdapter_NoOps()
{
var adapter = WbMeshAdapter.CreateUninitialized();
// Should not throw, even though there's no underlying mesh manager.
adapter.IncrementRefCount(0x01000001ul);
}
[Fact]
public void DecrementRefCount_OnUninitializedAdapter_NoOps()
{
var adapter = WbMeshAdapter.CreateUninitialized();
adapter.DecrementRefCount(0x01000001ul);
}
[Fact]
public void GetRenderData_OnUninitializedAdapter_ReturnsNull()
{
var adapter = WbMeshAdapter.CreateUninitialized();
Assert.Null(adapter.GetRenderData(0x01000001ul));
}
[Fact]
public void Tick_OnUninitializedAdapter_DoesNotThrow()
{
var adapter = WbMeshAdapter.CreateUninitialized();
adapter.Tick(); // no-op, no throw
adapter.Tick(); // idempotent
}
[Fact]
public void Tick_AfterDispose_DoesNotThrow()
{
var adapter = WbMeshAdapter.CreateUninitialized();
adapter.Dispose();
adapter.Tick(); // no-op, no throw
}
}