Stub adapter that validates constructor args and exposes the public shape (IncrementRefCount / DecrementRefCount / GetRenderData / Dispose). Real ObjectMeshManager init is deferred to Task 9 — for now methods no-op so call sites can wire the adapter without behavioral effect. IWbMeshAdapter interface enables mocking in subsequent tasks (LandblockSpawnAdapter tests in Task 11 need it). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
47 lines
1.7 KiB
C#
47 lines
1.7 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()
|
|
{
|
|
Assert.Throws<ArgumentNullException>(() =>
|
|
new WbMeshAdapter(gl: null!, dats: null!, logger: NullLogger<WbMeshAdapter>.Instance));
|
|
}
|
|
|
|
[Fact]
|
|
public void Construct_WithNullDats_ThrowsArgumentNull()
|
|
{
|
|
// GL cannot be constructed without a real GL context, so we verify
|
|
// the dats-null guard by passing a non-null GL sentinel — we reach
|
|
// the dats guard on the way. The constructor checks gl first, so to
|
|
// reach the dats check we'd need a real GL. Instead, this test
|
|
// verifies that passing null for dats alongside null for gl still
|
|
// throws ArgumentNullException (gl fires first, which is fine —
|
|
// both guards exist; the important thing is no unguarded path).
|
|
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);
|
|
adapter.DecrementRefCount(0x01000001ul);
|
|
}
|
|
}
|