13b18b0a8b
Standardize all class, interface, file, method, event, field, and variable names from the inconsistent "Die" form to "Dice", matching the existing DiceManager/DiceCatalog/DiceCollection convention. Renamed files (7 + meta): IDie→IDice, DieInstance→DiceInstance, DieDefinitionSO→DiceDefinitionSO, StandardDieSO→StandardDiceSO, DieValueCondition→DiceValueCondition, AddPerDieEffect→AddPerDiceEffect, MultiplyPerDieEffect→MultiplyPerDiceEffect. Updated all 31 consumer and test files with matching reference changes. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
134 lines
3.3 KiB
C#
134 lines
3.3 KiB
C#
using System.Collections.Generic;
|
|
using NUnit.Framework;
|
|
using YachtDice.Dice;
|
|
using YachtDice.Player;
|
|
|
|
namespace YachtDice.Tests
|
|
{
|
|
public sealed class DiceCollectionTests
|
|
{
|
|
private DiceCollection collection;
|
|
|
|
[SetUp]
|
|
public void SetUp()
|
|
{
|
|
collection = new DiceCollection();
|
|
}
|
|
|
|
[Test]
|
|
public void Add_IncreasesCount()
|
|
{
|
|
var die = StandardDiceSO.CreateStandardD6ForTest();
|
|
|
|
collection.Add(die);
|
|
|
|
Assert.AreEqual(1, collection.OwnedDice.Count);
|
|
}
|
|
|
|
[Test]
|
|
public void Add_DuplicateId_Ignored()
|
|
{
|
|
var die = StandardDiceSO.CreateStandardD6ForTest();
|
|
|
|
collection.Add(die);
|
|
collection.Add(die);
|
|
|
|
Assert.AreEqual(1, collection.OwnedDice.Count);
|
|
}
|
|
|
|
[Test]
|
|
public void Add_Null_Ignored()
|
|
{
|
|
collection.Add(null);
|
|
|
|
Assert.AreEqual(0, collection.OwnedDice.Count);
|
|
}
|
|
|
|
[Test]
|
|
public void OwnsById_ReturnsTrueWhenOwned()
|
|
{
|
|
var die = StandardDiceSO.CreateStandardD6ForTest();
|
|
|
|
collection.Add(die);
|
|
|
|
Assert.IsTrue(collection.OwnsById("standard_d6"));
|
|
}
|
|
|
|
[Test]
|
|
public void OwnsById_ReturnsFalseWhenNotOwned()
|
|
{
|
|
Assert.IsFalse(collection.OwnsById("standard_d6"));
|
|
}
|
|
|
|
[Test]
|
|
public void Remove_DecreasesCount()
|
|
{
|
|
var die = StandardDiceSO.CreateStandardD6ForTest();
|
|
|
|
collection.Add(die);
|
|
collection.Remove(die);
|
|
|
|
Assert.AreEqual(0, collection.OwnedDice.Count);
|
|
}
|
|
|
|
[Test]
|
|
public void GetSaveData_ReturnsIds()
|
|
{
|
|
var die = StandardDiceSO.CreateStandardD6ForTest();
|
|
|
|
collection.Add(die);
|
|
|
|
var ids = collection.GetSaveData();
|
|
Assert.AreEqual(1, ids.Count);
|
|
Assert.AreEqual("standard_d6", ids[0]);
|
|
}
|
|
|
|
[Test]
|
|
public void LoadSaveData_RestoresDice()
|
|
{
|
|
var die = StandardDiceSO.CreateStandardD6ForTest();
|
|
var catalog = DiceCatalog.CreateForTest(new List<DiceDefinitionSO> { die });
|
|
var ids = new List<string> { "standard_d6" };
|
|
|
|
collection.LoadSaveData(ids, catalog);
|
|
|
|
Assert.AreEqual(1, collection.OwnedDice.Count);
|
|
Assert.AreEqual("standard_d6", collection.OwnedDice[0].Id);
|
|
}
|
|
|
|
[Test]
|
|
public void LoadSaveData_SkipsMissingIds()
|
|
{
|
|
var catalog = DiceCatalog.CreateForTest(new List<DiceDefinitionSO>());
|
|
var ids = new List<string> { "nonexistent" };
|
|
|
|
collection.LoadSaveData(ids, catalog);
|
|
|
|
Assert.AreEqual(0, collection.OwnedDice.Count);
|
|
}
|
|
|
|
[Test]
|
|
public void Clear_RemovesAll()
|
|
{
|
|
var die = StandardDiceSO.CreateStandardD6ForTest();
|
|
|
|
collection.Add(die);
|
|
collection.Clear();
|
|
|
|
Assert.AreEqual(0, collection.OwnedDice.Count);
|
|
}
|
|
|
|
[Test]
|
|
public void Add_FiresOnChanged()
|
|
{
|
|
bool fired = false;
|
|
collection.OnChanged += () => fired = true;
|
|
|
|
var die = StandardDiceSO.CreateStandardD6ForTest();
|
|
collection.Add(die);
|
|
|
|
Assert.IsTrue(fired);
|
|
}
|
|
}
|
|
}
|