refactor: TileRegistry replaces parallel tile/view collections
This commit is contained in:
49
Assets/Tests/EditMode/TileRegistryTests.cs
Normal file
49
Assets/Tests/EditMode/TileRegistryTests.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using NUnit.Framework;
|
||||
using Core.Domain;
|
||||
using Infrastructure.Unity;
|
||||
|
||||
namespace DecayGrid.Tests
|
||||
{
|
||||
public class TileRegistryTests
|
||||
{
|
||||
private TileRegistry _registry;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp() => _registry = new TileRegistry();
|
||||
|
||||
[Test]
|
||||
public void Register_AddsToAllTiles()
|
||||
{
|
||||
var tile = new Tile("0_0_0", 0, 0.5f, 2f);
|
||||
_registry.Register(tile);
|
||||
Assert.AreEqual(1, _registry.AllTiles.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindTiles_ReturnsMatchingTiles()
|
||||
{
|
||||
var tile = new Tile("0_0_0", 0, 0.5f, 2f);
|
||||
_registry.Register(tile);
|
||||
var result = _registry.FindTiles(t => t.CurrentState == TileState.Stable);
|
||||
Assert.AreEqual(1, result.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void FindTiles_ExcludesNonMatchingTiles()
|
||||
{
|
||||
var tile = new Tile("0_0_0", 0, 0.5f, 2f);
|
||||
tile.StepOn(); // Now Warning
|
||||
_registry.Register(tile);
|
||||
var result = _registry.FindTiles(t => t.CurrentState == TileState.Stable);
|
||||
Assert.AreEqual(0, result.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TryGetView_ReturnsFalse_WhenNoViewRegistered()
|
||||
{
|
||||
var tile = new Tile("0_0_0", 0, 0.5f, 2f);
|
||||
_registry.Register(tile); // no view
|
||||
Assert.IsFalse(_registry.TryGetView("0_0_0", out _));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user