[Fix] Refactor project
This commit is contained in:
@@ -7,12 +7,12 @@ namespace YachtDice.Tests
|
||||
{
|
||||
public sealed class DiceCollectionTests
|
||||
{
|
||||
private DiceCollection collection;
|
||||
private DiceCollection _collection;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
collection = new DiceCollection();
|
||||
_collection = new DiceCollection();
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -20,9 +20,9 @@ namespace YachtDice.Tests
|
||||
{
|
||||
var die = StandardDice.CreateStandardD6ForTest();
|
||||
|
||||
collection.Add(die);
|
||||
_collection.Add(die);
|
||||
|
||||
Assert.AreEqual(1, collection.OwnedDice.Count);
|
||||
Assert.AreEqual(1, _collection.OwnedDice.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -30,18 +30,18 @@ namespace YachtDice.Tests
|
||||
{
|
||||
var die = StandardDice.CreateStandardD6ForTest();
|
||||
|
||||
collection.Add(die);
|
||||
collection.Add(die);
|
||||
_collection.Add(die);
|
||||
_collection.Add(die);
|
||||
|
||||
Assert.AreEqual(1, collection.OwnedDice.Count);
|
||||
Assert.AreEqual(1, _collection.OwnedDice.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Add_Null_Ignored()
|
||||
{
|
||||
collection.Add(null);
|
||||
_collection.Add(null);
|
||||
|
||||
Assert.AreEqual(0, collection.OwnedDice.Count);
|
||||
Assert.AreEqual(0, _collection.OwnedDice.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -49,15 +49,15 @@ namespace YachtDice.Tests
|
||||
{
|
||||
var die = StandardDice.CreateStandardD6ForTest();
|
||||
|
||||
collection.Add(die);
|
||||
_collection.Add(die);
|
||||
|
||||
Assert.IsTrue(collection.OwnsById("standard_d6"));
|
||||
Assert.IsTrue(_collection.OwnsById("standard_d6"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OwnsById_ReturnsFalseWhenNotOwned()
|
||||
{
|
||||
Assert.IsFalse(collection.OwnsById("standard_d6"));
|
||||
Assert.IsFalse(_collection.OwnsById("standard_d6"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -65,10 +65,10 @@ namespace YachtDice.Tests
|
||||
{
|
||||
var die = StandardDice.CreateStandardD6ForTest();
|
||||
|
||||
collection.Add(die);
|
||||
collection.Remove(die);
|
||||
_collection.Add(die);
|
||||
_collection.Remove(die);
|
||||
|
||||
Assert.AreEqual(0, collection.OwnedDice.Count);
|
||||
Assert.AreEqual(0, _collection.OwnedDice.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -76,9 +76,9 @@ namespace YachtDice.Tests
|
||||
{
|
||||
var die = StandardDice.CreateStandardD6ForTest();
|
||||
|
||||
collection.Add(die);
|
||||
_collection.Add(die);
|
||||
|
||||
var ids = collection.GetSaveData();
|
||||
var ids = _collection.GetSaveData();
|
||||
Assert.AreEqual(1, ids.Count);
|
||||
Assert.AreEqual("standard_d6", ids[0]);
|
||||
}
|
||||
@@ -90,10 +90,10 @@ namespace YachtDice.Tests
|
||||
var catalog = DiceCatalog.CreateForTest(new List<DiceDefinition> { die });
|
||||
var ids = new List<string> { "standard_d6" };
|
||||
|
||||
collection.LoadSaveData(ids, catalog);
|
||||
_collection.LoadSaveData(ids, catalog);
|
||||
|
||||
Assert.AreEqual(1, collection.OwnedDice.Count);
|
||||
Assert.AreEqual("standard_d6", collection.OwnedDice[0].Id);
|
||||
Assert.AreEqual(1, _collection.OwnedDice.Count);
|
||||
Assert.AreEqual("standard_d6", _collection.OwnedDice[0].Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -102,9 +102,9 @@ namespace YachtDice.Tests
|
||||
var catalog = DiceCatalog.CreateForTest(new List<DiceDefinition>());
|
||||
var ids = new List<string> { "nonexistent" };
|
||||
|
||||
collection.LoadSaveData(ids, catalog);
|
||||
_collection.LoadSaveData(ids, catalog);
|
||||
|
||||
Assert.AreEqual(0, collection.OwnedDice.Count);
|
||||
Assert.AreEqual(0, _collection.OwnedDice.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -112,20 +112,20 @@ namespace YachtDice.Tests
|
||||
{
|
||||
var die = StandardDice.CreateStandardD6ForTest();
|
||||
|
||||
collection.Add(die);
|
||||
collection.Clear();
|
||||
_collection.Add(die);
|
||||
_collection.Clear();
|
||||
|
||||
Assert.AreEqual(0, collection.OwnedDice.Count);
|
||||
Assert.AreEqual(0, _collection.OwnedDice.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Add_FiresOnChanged()
|
||||
{
|
||||
bool fired = false;
|
||||
collection.OnChanged += () => fired = true;
|
||||
_collection.OnChanged += () => fired = true;
|
||||
|
||||
var die = StandardDice.CreateStandardD6ForTest();
|
||||
collection.Add(die);
|
||||
_collection.Add(die);
|
||||
|
||||
Assert.IsTrue(fired);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
using YachtDice.Inventory;
|
||||
using YachtDice.Modifiers.Definition;
|
||||
using YachtDice.Modifiers.Runtime;
|
||||
@@ -8,14 +7,14 @@ namespace YachtDice.Tests
|
||||
{
|
||||
public class InventoryModelTests
|
||||
{
|
||||
private ModifierRegistry registry;
|
||||
private InventoryModel inventory;
|
||||
private ModifierRegistry _registry;
|
||||
private InventoryModel _inventory;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
registry = new ModifierRegistry(3);
|
||||
inventory = new InventoryModel(registry);
|
||||
_registry = new ModifierRegistry(3);
|
||||
_inventory = new InventoryModel(_registry);
|
||||
}
|
||||
|
||||
private ModifierDefinition CreateTestDef(string id = "test",
|
||||
@@ -28,22 +27,22 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void AddModifier_IncreasesCount()
|
||||
{
|
||||
inventory.AddModifier(CreateTestDef());
|
||||
_inventory.AddModifier(CreateTestDef());
|
||||
|
||||
Assert.AreEqual(1, inventory.OwnedModifiers.Count);
|
||||
Assert.AreEqual(1, _inventory.OwnedModifiers.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TryActivate_SucceedsWithinSlotLimit()
|
||||
{
|
||||
inventory.AddModifier(CreateTestDef("a"));
|
||||
var mod = inventory.OwnedModifiers[0];
|
||||
_inventory.AddModifier(CreateTestDef("a"));
|
||||
var mod = _inventory.OwnedModifiers[0];
|
||||
|
||||
bool result = inventory.TryActivate(mod);
|
||||
bool result = _inventory.TryActivate(mod);
|
||||
|
||||
Assert.IsTrue(result);
|
||||
Assert.IsTrue(mod.IsActive);
|
||||
Assert.AreEqual(1, inventory.ActiveCount);
|
||||
Assert.AreEqual(1, _inventory.ActiveCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -51,53 +50,53 @@ namespace YachtDice.Tests
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
inventory.AddModifier(CreateTestDef($"m{i}"));
|
||||
inventory.TryActivate(inventory.OwnedModifiers[i]);
|
||||
_inventory.AddModifier(CreateTestDef($"m{i}"));
|
||||
_inventory.TryActivate(_inventory.OwnedModifiers[i]);
|
||||
}
|
||||
|
||||
inventory.AddModifier(CreateTestDef("extra"));
|
||||
var extra = inventory.OwnedModifiers[3];
|
||||
bool result = inventory.TryActivate(extra);
|
||||
_inventory.AddModifier(CreateTestDef("extra"));
|
||||
var extra = _inventory.OwnedModifiers[3];
|
||||
bool result = _inventory.TryActivate(extra);
|
||||
|
||||
Assert.IsFalse(result);
|
||||
Assert.IsFalse(extra.IsActive);
|
||||
Assert.AreEqual(3, inventory.ActiveCount);
|
||||
Assert.AreEqual(3, _inventory.ActiveCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Deactivate_FreesSlot()
|
||||
{
|
||||
inventory.AddModifier(CreateTestDef());
|
||||
var mod = inventory.OwnedModifiers[0];
|
||||
inventory.TryActivate(mod);
|
||||
_inventory.AddModifier(CreateTestDef());
|
||||
var mod = _inventory.OwnedModifiers[0];
|
||||
_inventory.TryActivate(mod);
|
||||
|
||||
inventory.Deactivate(mod);
|
||||
_inventory.Deactivate(mod);
|
||||
|
||||
Assert.IsFalse(mod.IsActive);
|
||||
Assert.AreEqual(0, inventory.ActiveCount);
|
||||
Assert.AreEqual(0, _inventory.ActiveCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RemoveModifier_DeactivatesAndRemoves()
|
||||
{
|
||||
inventory.AddModifier(CreateTestDef());
|
||||
var mod = inventory.OwnedModifiers[0];
|
||||
inventory.TryActivate(mod);
|
||||
_inventory.AddModifier(CreateTestDef());
|
||||
var mod = _inventory.OwnedModifiers[0];
|
||||
_inventory.TryActivate(mod);
|
||||
|
||||
inventory.RemoveModifier(mod);
|
||||
_inventory.RemoveModifier(mod);
|
||||
|
||||
Assert.AreEqual(0, inventory.OwnedModifiers.Count);
|
||||
Assert.AreEqual(0, inventory.ActiveCount);
|
||||
Assert.AreEqual(0, _inventory.OwnedModifiers.Count);
|
||||
Assert.AreEqual(0, _inventory.ActiveCount);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConsumeUseOnActive_DecrementsUses()
|
||||
{
|
||||
inventory.AddModifier(CreateTestDef("ltd", hasLimitedUses: true, maxUses: 3));
|
||||
var mod = inventory.OwnedModifiers[0];
|
||||
inventory.TryActivate(mod);
|
||||
_inventory.AddModifier(CreateTestDef("ltd", hasLimitedUses: true, maxUses: 3));
|
||||
var mod = _inventory.OwnedModifiers[0];
|
||||
_inventory.TryActivate(mod);
|
||||
|
||||
inventory.ConsumeUseOnActive();
|
||||
_inventory.ConsumeUseOnActive();
|
||||
|
||||
Assert.AreEqual(2, mod.RemainingUses);
|
||||
}
|
||||
@@ -105,36 +104,36 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void ConsumeUseOnActive_RemovesExpired()
|
||||
{
|
||||
inventory.AddModifier(CreateTestDef("ltd", hasLimitedUses: true, maxUses: 1));
|
||||
var mod = inventory.OwnedModifiers[0];
|
||||
inventory.TryActivate(mod);
|
||||
_inventory.AddModifier(CreateTestDef("ltd", hasLimitedUses: true, maxUses: 1));
|
||||
var mod = _inventory.OwnedModifiers[0];
|
||||
_inventory.TryActivate(mod);
|
||||
|
||||
inventory.ConsumeUseOnActive();
|
||||
_inventory.ConsumeUseOnActive();
|
||||
|
||||
Assert.AreEqual(0, inventory.OwnedModifiers.Count);
|
||||
Assert.AreEqual(0, _inventory.OwnedModifiers.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ConsumeUseOnActive_IgnoresPermanent()
|
||||
{
|
||||
inventory.AddModifier(CreateTestDef("perm"));
|
||||
var mod = inventory.OwnedModifiers[0];
|
||||
inventory.TryActivate(mod);
|
||||
_inventory.AddModifier(CreateTestDef("perm"));
|
||||
var mod = _inventory.OwnedModifiers[0];
|
||||
_inventory.TryActivate(mod);
|
||||
|
||||
inventory.ConsumeUseOnActive();
|
||||
_inventory.ConsumeUseOnActive();
|
||||
|
||||
Assert.AreEqual(1, inventory.OwnedModifiers.Count);
|
||||
Assert.AreEqual(1, _inventory.OwnedModifiers.Count);
|
||||
Assert.IsTrue(mod.IsActive);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetActiveModifierDefinitions_ReturnsOnlyActive()
|
||||
{
|
||||
inventory.AddModifier(CreateTestDef("a"));
|
||||
inventory.AddModifier(CreateTestDef("b"));
|
||||
inventory.TryActivate(inventory.OwnedModifiers[0]);
|
||||
_inventory.AddModifier(CreateTestDef("a"));
|
||||
_inventory.AddModifier(CreateTestDef("b"));
|
||||
_inventory.TryActivate(_inventory.OwnedModifiers[0]);
|
||||
|
||||
var active = inventory.GetActiveModifierDefinitions();
|
||||
var active = _inventory.GetActiveModifierDefinitions();
|
||||
|
||||
Assert.AreEqual(1, active.Count);
|
||||
}
|
||||
@@ -142,19 +141,19 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void SetMaxActiveSlots_AllowsExpansion()
|
||||
{
|
||||
inventory.SetMaxActiveSlots(10);
|
||||
_inventory.SetMaxActiveSlots(10);
|
||||
|
||||
Assert.AreEqual(10, inventory.MaxActiveSlots);
|
||||
Assert.AreEqual(10, _inventory.MaxActiveSlots);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void OnActiveModifiersChanged_FiredOnActivate()
|
||||
{
|
||||
bool fired = false;
|
||||
inventory.OnActiveModifiersChanged += _ => fired = true;
|
||||
inventory.AddModifier(CreateTestDef());
|
||||
_inventory.OnActiveModifiersChanged += _ => fired = true;
|
||||
_inventory.AddModifier(CreateTestDef());
|
||||
|
||||
inventory.TryActivate(inventory.OwnedModifiers[0]);
|
||||
_inventory.TryActivate(_inventory.OwnedModifiers[0]);
|
||||
|
||||
Assert.IsTrue(fired);
|
||||
}
|
||||
|
||||
@@ -5,24 +5,23 @@ using YachtDice.Modifiers.Core;
|
||||
using YachtDice.Modifiers.Definition;
|
||||
using YachtDice.Modifiers.Effects;
|
||||
using YachtDice.Modifiers.Runtime;
|
||||
using YachtDice.Scoring;
|
||||
|
||||
namespace YachtDice.Tests
|
||||
{
|
||||
public class ModifierEffectTests
|
||||
{
|
||||
private CategoryDefinition testCategory;
|
||||
private CategoryDefinition _testCategory;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
testCategory = SumAllCategory.CreateForTest("chance", "Шанс");
|
||||
_testCategory = SumAllCategory.CreateForTest("chance", "Шанс");
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
Object.DestroyImmediate(testCategory);
|
||||
Object.DestroyImmediate(_testCategory);
|
||||
}
|
||||
|
||||
private ModifierInstance CreateInstance(string id = "test")
|
||||
@@ -37,7 +36,7 @@ namespace YachtDice.Tests
|
||||
{
|
||||
BaseScore = baseScore,
|
||||
DiceValues = dice,
|
||||
Category = testCategory,
|
||||
Category = _testCategory,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -14,41 +14,41 @@ namespace YachtDice.Tests
|
||||
{
|
||||
public class ModifierPipelineTests
|
||||
{
|
||||
private ModifierRegistry registry;
|
||||
private ModifierPipeline pipeline;
|
||||
private ModifierRegistry _registry;
|
||||
private ModifierPipeline _pipeline;
|
||||
|
||||
// Тестовые категории
|
||||
private CategoryDefinition chanceCategory;
|
||||
private CategoryDefinition fullHouseCategory;
|
||||
private CategoryDefinition onesCategory;
|
||||
private CategoryDefinition threesCategory;
|
||||
private CategoryDefinition foursCategory;
|
||||
private CategoryDefinition sixesCategory;
|
||||
private CategoryDefinition _chanceCategory;
|
||||
private CategoryDefinition _fullHouseCategory;
|
||||
private CategoryDefinition _onesCategory;
|
||||
private CategoryDefinition _threesCategory;
|
||||
private CategoryDefinition _foursCategory;
|
||||
private CategoryDefinition _sixesCategory;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
registry = new ModifierRegistry(10);
|
||||
pipeline = new ModifierPipeline(registry);
|
||||
pipeline.TracingEnabled = false;
|
||||
_registry = new ModifierRegistry(10);
|
||||
_pipeline = new ModifierPipeline(_registry);
|
||||
_pipeline.TracingEnabled = false;
|
||||
|
||||
chanceCategory = SumAllCategory.CreateForTest("chance", "Шанс");
|
||||
fullHouseCategory = FullHouseCategory.CreateForTest("full_house", "Фулл-хаус");
|
||||
onesCategory = SumOfValueCategory.CreateForTest("ones", "Единицы", 1);
|
||||
threesCategory = SumOfValueCategory.CreateForTest("threes", "Тройки", 3);
|
||||
foursCategory = SumOfValueCategory.CreateForTest("fours", "Четвёрки", 4);
|
||||
sixesCategory = SumOfValueCategory.CreateForTest("sixes", "Шестёрки", 6);
|
||||
_chanceCategory = SumAllCategory.CreateForTest("chance", "Шанс");
|
||||
_fullHouseCategory = FullHouseCategory.CreateForTest("full_house", "Фулл-хаус");
|
||||
_onesCategory = SumOfValueCategory.CreateForTest("ones", "Единицы", 1);
|
||||
_threesCategory = SumOfValueCategory.CreateForTest("threes", "Тройки", 3);
|
||||
_foursCategory = SumOfValueCategory.CreateForTest("fours", "Четвёрки", 4);
|
||||
_sixesCategory = SumOfValueCategory.CreateForTest("sixes", "Шестёрки", 6);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
Object.DestroyImmediate(chanceCategory);
|
||||
Object.DestroyImmediate(fullHouseCategory);
|
||||
Object.DestroyImmediate(onesCategory);
|
||||
Object.DestroyImmediate(threesCategory);
|
||||
Object.DestroyImmediate(foursCategory);
|
||||
Object.DestroyImmediate(sixesCategory);
|
||||
Object.DestroyImmediate(_chanceCategory);
|
||||
Object.DestroyImmediate(_fullHouseCategory);
|
||||
Object.DestroyImmediate(_onesCategory);
|
||||
Object.DestroyImmediate(_threesCategory);
|
||||
Object.DestroyImmediate(_foursCategory);
|
||||
Object.DestroyImmediate(_sixesCategory);
|
||||
}
|
||||
|
||||
private ModifierDefinition CreateDef(string id,
|
||||
@@ -63,8 +63,8 @@ namespace YachtDice.Tests
|
||||
|
||||
private void RegisterAndActivate(ModifierDefinition def)
|
||||
{
|
||||
var inst = registry.Add(def);
|
||||
registry.TryActivate(inst);
|
||||
var inst = _registry.Add(def);
|
||||
_registry.TryActivate(inst);
|
||||
}
|
||||
|
||||
private ModifierContext CreateScoringContext(int baseScore, int[] dice, CategoryDefinition category)
|
||||
@@ -74,7 +74,7 @@ namespace YachtDice.Tests
|
||||
BaseScore = baseScore,
|
||||
DiceValues = dice,
|
||||
Category = category,
|
||||
AllActiveModifiers = registry.Active,
|
||||
AllActiveModifiers = _registry.Active,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -94,8 +94,8 @@ namespace YachtDice.Tests
|
||||
RegisterAndActivate(mulDef);
|
||||
RegisterAndActivate(addDef);
|
||||
|
||||
var ctx = CreateScoringContext(20, new[] { 1, 2, 3, 4, 5 }, chanceCategory);
|
||||
var result = pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
var ctx = CreateScoringContext(20, new[] { 1, 2, 3, 4, 5 }, _chanceCategory);
|
||||
var result = _pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
|
||||
// (20 + 10) * 2 = 60
|
||||
Assert.AreEqual(60, result.FinalScore);
|
||||
@@ -115,8 +115,8 @@ namespace YachtDice.Tests
|
||||
RegisterAndActivate(postDef);
|
||||
RegisterAndActivate(mulDef);
|
||||
|
||||
var ctx = CreateScoringContext(10, new[] { 1, 2, 3, 4, 5 }, chanceCategory);
|
||||
var result = pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
var ctx = CreateScoringContext(10, new[] { 1, 2, 3, 4, 5 }, _chanceCategory);
|
||||
var result = _pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
|
||||
// (10 + 0) * 2 * 3 = 60
|
||||
Assert.AreEqual(60, result.FinalScore);
|
||||
@@ -127,7 +127,7 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void Execute_ConditionFails_SkipsEffect()
|
||||
{
|
||||
var condition = CategoryCondition.CreateForTest(fullHouseCategory);
|
||||
var condition = CategoryCondition.CreateForTest(_fullHouseCategory);
|
||||
var effect = AddFlatScoreEffect.CreateForTest(100);
|
||||
|
||||
var def = CreateDef("fh-bonus", TriggerType.OnCategoryScored,
|
||||
@@ -137,8 +137,8 @@ namespace YachtDice.Tests
|
||||
RegisterAndActivate(def);
|
||||
|
||||
// Scoring Ones, not FullHouse — condition should fail
|
||||
var ctx = CreateScoringContext(5, new[] { 1, 1, 1, 1, 1 }, onesCategory);
|
||||
var result = pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
var ctx = CreateScoringContext(5, new[] { 1, 1, 1, 1, 1 }, _onesCategory);
|
||||
var result = _pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
|
||||
Assert.AreEqual(0, result.FlatBonus);
|
||||
Assert.AreEqual(5, result.FinalScore);
|
||||
@@ -147,7 +147,7 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void Execute_ConditionPasses_AppliesEffect()
|
||||
{
|
||||
var condition = CategoryCondition.CreateForTest(fullHouseCategory);
|
||||
var condition = CategoryCondition.CreateForTest(_fullHouseCategory);
|
||||
var effect = AddFlatScoreEffect.CreateForTest(15);
|
||||
|
||||
var def = CreateDef("fh-bonus", TriggerType.OnCategoryScored,
|
||||
@@ -156,8 +156,8 @@ namespace YachtDice.Tests
|
||||
|
||||
RegisterAndActivate(def);
|
||||
|
||||
var ctx = CreateScoringContext(25, new[] { 3, 3, 3, 2, 2 }, fullHouseCategory);
|
||||
var result = pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
var ctx = CreateScoringContext(25, new[] { 3, 3, 3, 2, 2 }, _fullHouseCategory);
|
||||
var result = _pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
|
||||
Assert.AreEqual(15, result.FlatBonus);
|
||||
Assert.AreEqual(40, result.FinalScore);
|
||||
@@ -174,8 +174,8 @@ namespace YachtDice.Tests
|
||||
|
||||
RegisterAndActivate(def);
|
||||
|
||||
var ctx = CreateScoringContext(10, new[] { 1, 2, 3, 4, 5 }, chanceCategory);
|
||||
var result = pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
var ctx = CreateScoringContext(10, new[] { 1, 2, 3, 4, 5 }, _chanceCategory);
|
||||
var result = _pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
|
||||
Assert.AreEqual(0, result.FlatBonus);
|
||||
Assert.AreEqual(10, result.FinalScore);
|
||||
@@ -206,8 +206,8 @@ namespace YachtDice.Tests
|
||||
RegisterAndActivate(def1);
|
||||
|
||||
// dice: [3, 3, 3, 1, 2] — 3 threes
|
||||
var ctx = CreateScoringContext(9, new[] { 3, 3, 3, 1, 2 }, threesCategory);
|
||||
var result = pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
var ctx = CreateScoringContext(9, new[] { 3, 3, 3, 1, 2 }, _threesCategory);
|
||||
var result = _pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
|
||||
Assert.AreEqual(16, result.FlatBonus);
|
||||
Assert.AreEqual(168, result.FinalScore);
|
||||
@@ -218,8 +218,8 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void Execute_NoActiveModifiers_NoChange()
|
||||
{
|
||||
var ctx = CreateScoringContext(10, new[] { 1, 2, 3, 4, 5 }, chanceCategory);
|
||||
var result = pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
var ctx = CreateScoringContext(10, new[] { 1, 2, 3, 4, 5 }, _chanceCategory);
|
||||
var result = _pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
|
||||
Assert.AreEqual(10, result.FinalScore);
|
||||
Assert.AreEqual(0, result.FlatBonus);
|
||||
@@ -233,10 +233,10 @@ namespace YachtDice.Tests
|
||||
var def = CreateDef("inactive", TriggerType.OnCategoryScored, null,
|
||||
new List<Effect> { effect });
|
||||
|
||||
registry.Add(def);
|
||||
_registry.Add(def);
|
||||
|
||||
var ctx = CreateScoringContext(10, new[] { 1, 2, 3, 4, 5 }, chanceCategory);
|
||||
var result = pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
var ctx = CreateScoringContext(10, new[] { 1, 2, 3, 4, 5 }, _chanceCategory);
|
||||
var result = _pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
|
||||
Assert.AreEqual(0, result.FlatBonus);
|
||||
Assert.AreEqual(10, result.FinalScore);
|
||||
@@ -255,8 +255,8 @@ namespace YachtDice.Tests
|
||||
|
||||
RegisterAndActivate(def);
|
||||
|
||||
var ctx = CreateScoringContext(10, new[] { 1, 2, 3, 4, 5 }, chanceCategory);
|
||||
var result = pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
var ctx = CreateScoringContext(10, new[] { 1, 2, 3, 4, 5 }, _chanceCategory);
|
||||
var result = _pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
|
||||
Assert.AreEqual(10, result.FlatBonus);
|
||||
Assert.AreEqual(25, result.CurrencyDelta);
|
||||
@@ -268,7 +268,7 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void Execute_TracingEnabled_PopulatesDebugLog()
|
||||
{
|
||||
pipeline.TracingEnabled = true;
|
||||
_pipeline.TracingEnabled = true;
|
||||
|
||||
var effect = AddFlatScoreEffect.CreateForTest(10);
|
||||
var def = CreateDef("traced", TriggerType.OnCategoryScored, null,
|
||||
@@ -276,8 +276,8 @@ namespace YachtDice.Tests
|
||||
|
||||
RegisterAndActivate(def);
|
||||
|
||||
var ctx = CreateScoringContext(10, new[] { 1, 2, 3, 4, 5 }, chanceCategory);
|
||||
var result = pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
var ctx = CreateScoringContext(10, new[] { 1, 2, 3, 4, 5 }, _chanceCategory);
|
||||
var result = _pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
|
||||
Assert.IsNotNull(result.DebugLog);
|
||||
Assert.IsTrue(result.DebugLog.Count > 0);
|
||||
@@ -298,14 +298,14 @@ namespace YachtDice.Tests
|
||||
RegisterAndActivate(def);
|
||||
|
||||
// Only 2 sixes — condition requires 3
|
||||
var ctx = CreateScoringContext(12, new[] { 6, 6, 1, 2, 3 }, sixesCategory);
|
||||
var result = pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
var ctx = CreateScoringContext(12, new[] { 6, 6, 1, 2, 3 }, _sixesCategory);
|
||||
var result = _pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
|
||||
Assert.AreEqual(0, result.FlatBonus);
|
||||
|
||||
// 3 sixes — condition passes
|
||||
var ctx2 = CreateScoringContext(18, new[] { 6, 6, 6, 1, 2 }, sixesCategory);
|
||||
var result2 = pipeline.Execute(TriggerType.OnCategoryScored, ctx2).GetAwaiter().GetResult();
|
||||
var ctx2 = CreateScoringContext(18, new[] { 6, 6, 6, 1, 2 }, _sixesCategory);
|
||||
var result2 = _pipeline.Execute(TriggerType.OnCategoryScored, ctx2).GetAwaiter().GetResult();
|
||||
|
||||
Assert.AreEqual(100, result2.FlatBonus);
|
||||
}
|
||||
@@ -325,14 +325,14 @@ namespace YachtDice.Tests
|
||||
RegisterAndActivate(def);
|
||||
|
||||
// Below threshold
|
||||
var ctx = CreateScoringContext(15, new[] { 3, 3, 3, 3, 3 }, threesCategory);
|
||||
var result = pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
var ctx = CreateScoringContext(15, new[] { 3, 3, 3, 3, 3 }, _threesCategory);
|
||||
var result = _pipeline.Execute(TriggerType.OnCategoryScored, ctx).GetAwaiter().GetResult();
|
||||
|
||||
Assert.AreEqual(1f, result.Multiplier);
|
||||
|
||||
// At threshold
|
||||
var ctx2 = CreateScoringContext(20, new[] { 4, 4, 4, 4, 4 }, foursCategory);
|
||||
var result2 = pipeline.Execute(TriggerType.OnCategoryScored, ctx2).GetAwaiter().GetResult();
|
||||
var ctx2 = CreateScoringContext(20, new[] { 4, 4, 4, 4, 4 }, _foursCategory);
|
||||
var result2 = _pipeline.Execute(TriggerType.OnCategoryScored, ctx2).GetAwaiter().GetResult();
|
||||
|
||||
Assert.AreEqual(2f, result2.Multiplier);
|
||||
}
|
||||
@@ -342,7 +342,7 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void ToScoreResult_ConvertsCorrectly()
|
||||
{
|
||||
var ctx = CreateScoringContext(10, new[] { 1, 2, 3, 4, 5 }, chanceCategory);
|
||||
var ctx = CreateScoringContext(10, new[] { 1, 2, 3, 4, 5 }, _chanceCategory);
|
||||
ctx.FlatBonus = 5;
|
||||
ctx.Multiplier = 2f;
|
||||
ctx.PostMultiplier = 1.5f;
|
||||
@@ -352,7 +352,7 @@ namespace YachtDice.Tests
|
||||
Assert.AreEqual(10, sr.baseScore);
|
||||
Assert.AreEqual(5, sr.flatBonus);
|
||||
Assert.AreEqual(3f, sr.multiplier, 0.001f); // 2 * 1.5
|
||||
Assert.AreEqual(chanceCategory, sr.category);
|
||||
Assert.AreEqual(_chanceCategory, sr.category);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,26 +9,26 @@ namespace YachtDice.Tests
|
||||
{
|
||||
public class ScoringSystemTests
|
||||
{
|
||||
private CategoryDefinition yachtCategory;
|
||||
private CategoryDefinition onesCategory;
|
||||
private CategoryDefinition twosCategory;
|
||||
private CategoryDefinition chanceCategory;
|
||||
private CategoryCatalog catalog;
|
||||
private DiceDefinition standardDice;
|
||||
private CategoryDefinition _yachtCategory;
|
||||
private CategoryDefinition _onesCategory;
|
||||
private CategoryDefinition _twosCategory;
|
||||
private CategoryDefinition _chanceCategory;
|
||||
private CategoryCatalog _catalog;
|
||||
private DiceDefinition _standardDice;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
standardDice = DiceDefinition.CreateForTest<StandardDice>("d6", "d6");
|
||||
_standardDice = DiceDefinition.CreateForTest<StandardDice>("d6", "d6");
|
||||
|
||||
yachtCategory = NOfAKindCategory.CreateForTest("yacht", "Яхта", 5, fixedScoreMode: true, score: 50);
|
||||
onesCategory = SumOfValueCategory.CreateForTest("ones", "Единицы", 1);
|
||||
twosCategory = SumOfValueCategory.CreateForTest("twos", "Двойки", 2);
|
||||
chanceCategory = SumAllCategory.CreateForTest("chance", "Шанс");
|
||||
_yachtCategory = NOfAKindCategory.CreateForTest("yacht", "Яхта", 5, fixedScoreMode: true, score: 50);
|
||||
_onesCategory = SumOfValueCategory.CreateForTest("ones", "Единицы", 1);
|
||||
_twosCategory = SumOfValueCategory.CreateForTest("twos", "Двойки", 2);
|
||||
_chanceCategory = SumAllCategory.CreateForTest("chance", "Шанс");
|
||||
|
||||
catalog = CategoryCatalog.CreateForTest(new List<CategoryDefinition>
|
||||
_catalog = CategoryCatalog.CreateForTest(new List<CategoryDefinition>
|
||||
{
|
||||
onesCategory, twosCategory, yachtCategory, chanceCategory
|
||||
_onesCategory, _twosCategory, _yachtCategory, _chanceCategory
|
||||
});
|
||||
}
|
||||
|
||||
@@ -38,12 +38,12 @@ namespace YachtDice.Tests
|
||||
foreach (var go in Object.FindObjectsByType<ScoringSystem>(FindObjectsSortMode.None))
|
||||
Object.DestroyImmediate(go.gameObject);
|
||||
|
||||
Object.DestroyImmediate(yachtCategory);
|
||||
Object.DestroyImmediate(onesCategory);
|
||||
Object.DestroyImmediate(twosCategory);
|
||||
Object.DestroyImmediate(chanceCategory);
|
||||
Object.DestroyImmediate(catalog);
|
||||
Object.DestroyImmediate(standardDice);
|
||||
Object.DestroyImmediate(_yachtCategory);
|
||||
Object.DestroyImmediate(_onesCategory);
|
||||
Object.DestroyImmediate(_twosCategory);
|
||||
Object.DestroyImmediate(_chanceCategory);
|
||||
Object.DestroyImmediate(_catalog);
|
||||
Object.DestroyImmediate(_standardDice);
|
||||
}
|
||||
|
||||
private ScoringSystem CreateScoringSystem()
|
||||
@@ -56,7 +56,7 @@ namespace YachtDice.Tests
|
||||
{
|
||||
var dice = new DiceInstance[values.Length];
|
||||
for (int i = 0; i < values.Length; i++)
|
||||
dice[i] = new DiceInstance(standardDice, values[i]);
|
||||
dice[i] = new DiceInstance(_standardDice, values[i]);
|
||||
return dice;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace YachtDice.Tests
|
||||
{
|
||||
var system = CreateScoringSystem();
|
||||
var dice = CreateDice(6, 6, 6, 6, 6);
|
||||
var result = system.ScoreCategory(dice, yachtCategory);
|
||||
var result = system.ScoreCategory(dice, _yachtCategory);
|
||||
|
||||
Assert.AreEqual(50, result.baseScore);
|
||||
Assert.AreEqual(0, result.flatBonus);
|
||||
@@ -87,9 +87,9 @@ namespace YachtDice.Tests
|
||||
};
|
||||
|
||||
var dice = CreateDice(1, 1, 1, 1, 1);
|
||||
system.ScoreCategory(dice, onesCategory);
|
||||
system.ScoreCategory(dice, _onesCategory);
|
||||
|
||||
Assert.AreEqual(onesCategory, firedCategory);
|
||||
Assert.AreEqual(_onesCategory, firedCategory);
|
||||
Assert.AreEqual(5, firedResult.baseScore);
|
||||
}
|
||||
|
||||
@@ -98,10 +98,10 @@ namespace YachtDice.Tests
|
||||
{
|
||||
var system = CreateScoringSystem();
|
||||
var dice = CreateDice(1, 2, 3, 4, 5);
|
||||
system.ScoreCategory(dice, chanceCategory);
|
||||
system.ScoreCategory(dice, _chanceCategory);
|
||||
|
||||
Assert.Throws<System.InvalidOperationException>(() =>
|
||||
system.ScoreCategory(dice, chanceCategory));
|
||||
system.ScoreCategory(dice, _chanceCategory));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -109,7 +109,7 @@ namespace YachtDice.Tests
|
||||
{
|
||||
var system = CreateScoringSystem();
|
||||
var dice = CreateDice(1, 2, 3, 4, 5);
|
||||
var result = system.PreviewScore(dice, chanceCategory);
|
||||
var result = system.PreviewScore(dice, _chanceCategory);
|
||||
|
||||
Assert.AreEqual(15, result.baseScore);
|
||||
Assert.AreEqual(0, result.flatBonus);
|
||||
@@ -120,8 +120,8 @@ namespace YachtDice.Tests
|
||||
public void TotalScore_SumsAllScoredCategories()
|
||||
{
|
||||
var system = CreateScoringSystem();
|
||||
system.ScoreCategory(CreateDice(1, 1, 1, 1, 1), onesCategory);
|
||||
system.ScoreCategory(CreateDice(2, 2, 2, 2, 2), twosCategory);
|
||||
system.ScoreCategory(CreateDice(1, 1, 1, 1, 1), _onesCategory);
|
||||
system.ScoreCategory(CreateDice(2, 2, 2, 2, 2), _twosCategory);
|
||||
|
||||
Assert.AreEqual(15, system.TotalScore); // 5 + 10
|
||||
}
|
||||
@@ -130,12 +130,12 @@ namespace YachtDice.Tests
|
||||
public void ResetScorecard_ClearsAll()
|
||||
{
|
||||
var system = CreateScoringSystem();
|
||||
system.ScoreCategory(CreateDice(1, 1, 1, 1, 1), onesCategory);
|
||||
system.ScoreCategory(CreateDice(1, 1, 1, 1, 1), _onesCategory);
|
||||
|
||||
system.ResetScorecard();
|
||||
|
||||
Assert.AreEqual(0, system.TotalScore);
|
||||
Assert.IsFalse(system.IsCategoryUsed(onesCategory));
|
||||
Assert.IsFalse(system.IsCategoryUsed(_onesCategory));
|
||||
}
|
||||
|
||||
// ── Category SO Unit Tests ──────────────────────────────────
|
||||
@@ -165,8 +165,8 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void NOfAKindCategory_Yacht_ReturnsFixedScore()
|
||||
{
|
||||
Assert.AreEqual(50, yachtCategory.Calculate(CreateDice(6, 6, 6, 6, 6)));
|
||||
Assert.AreEqual(0, yachtCategory.Calculate(CreateDice(6, 6, 6, 6, 1)));
|
||||
Assert.AreEqual(50, _yachtCategory.Calculate(CreateDice(6, 6, 6, 6, 6)));
|
||||
Assert.AreEqual(0, _yachtCategory.Calculate(CreateDice(6, 6, 6, 6, 1)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -206,8 +206,8 @@ namespace YachtDice.Tests
|
||||
[Test]
|
||||
public void SumAllCategory_SumsEverything()
|
||||
{
|
||||
Assert.AreEqual(15, chanceCategory.Calculate(CreateDice(1, 2, 3, 4, 5)));
|
||||
Assert.AreEqual(30, chanceCategory.Calculate(CreateDice(6, 6, 6, 6, 6)));
|
||||
Assert.AreEqual(15, _chanceCategory.Calculate(CreateDice(1, 2, 3, 4, 5)));
|
||||
Assert.AreEqual(30, _chanceCategory.Calculate(CreateDice(6, 6, 6, 6, 6)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,23 +12,23 @@ namespace YachtDice.Tests
|
||||
{
|
||||
public sealed class ShopModelTests
|
||||
{
|
||||
private CurrencyBank bank;
|
||||
private ModifierRegistry registry;
|
||||
private InventoryModel inventory;
|
||||
private DiceCollection diceCollection;
|
||||
private ShopModel shop;
|
||||
private CurrencyBank _bank;
|
||||
private ModifierRegistry _registry;
|
||||
private InventoryModel _inventory;
|
||||
private DiceCollection _diceCollection;
|
||||
private ShopModel _shop;
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
var go = new GameObject("Bank");
|
||||
bank = go.AddComponent<CurrencyBank>();
|
||||
bank.SetBalance(500);
|
||||
_bank = go.AddComponent<CurrencyBank>();
|
||||
_bank.SetBalance(500);
|
||||
|
||||
registry = new ModifierRegistry(5);
|
||||
inventory = new InventoryModel(registry);
|
||||
diceCollection = new DiceCollection();
|
||||
shop = new ShopModel(bank, inventory, diceCollection);
|
||||
_registry = new ModifierRegistry(5);
|
||||
_inventory = new InventoryModel(_registry);
|
||||
_diceCollection = new DiceCollection();
|
||||
_shop = new ShopModel(_bank, _inventory, _diceCollection);
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
@@ -52,24 +52,24 @@ namespace YachtDice.Tests
|
||||
{
|
||||
var mod = CreateDef("test", shopPrice: 100);
|
||||
|
||||
bool result = shop.TryPurchase(mod);
|
||||
bool result = _shop.TryPurchase(mod);
|
||||
|
||||
Assert.IsTrue(result);
|
||||
Assert.AreEqual(400, bank.Balance);
|
||||
Assert.AreEqual(1, inventory.OwnedModifiers.Count);
|
||||
Assert.AreEqual(400, _bank.Balance);
|
||||
Assert.AreEqual(1, _inventory.OwnedModifiers.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TryPurchase_FailsWhenBroke()
|
||||
{
|
||||
bank.SetBalance(10);
|
||||
_bank.SetBalance(10);
|
||||
var mod = CreateDef("test", shopPrice: 100);
|
||||
|
||||
bool result = shop.TryPurchase(mod);
|
||||
bool result = _shop.TryPurchase(mod);
|
||||
|
||||
Assert.IsFalse(result);
|
||||
Assert.AreEqual(10, bank.Balance);
|
||||
Assert.AreEqual(0, inventory.OwnedModifiers.Count);
|
||||
Assert.AreEqual(10, _bank.Balance);
|
||||
Assert.AreEqual(0, _inventory.OwnedModifiers.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -77,12 +77,12 @@ namespace YachtDice.Tests
|
||||
{
|
||||
var mod = CreateDef("perm", shopPrice: 100);
|
||||
|
||||
shop.TryPurchase(mod);
|
||||
bool secondResult = shop.TryPurchase(mod);
|
||||
_shop.TryPurchase(mod);
|
||||
bool secondResult = _shop.TryPurchase(mod);
|
||||
|
||||
Assert.IsFalse(secondResult);
|
||||
Assert.AreEqual(400, bank.Balance);
|
||||
Assert.AreEqual(1, inventory.OwnedModifiers.Count);
|
||||
Assert.AreEqual(400, _bank.Balance);
|
||||
Assert.AreEqual(1, _inventory.OwnedModifiers.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -90,23 +90,23 @@ namespace YachtDice.Tests
|
||||
{
|
||||
var mod = CreateDef("limited", hasLimitedUses: true, maxUses: 3, shopPrice: 100);
|
||||
|
||||
shop.TryPurchase(mod);
|
||||
bool secondResult = shop.TryPurchase(mod);
|
||||
_shop.TryPurchase(mod);
|
||||
bool secondResult = _shop.TryPurchase(mod);
|
||||
|
||||
Assert.IsTrue(secondResult);
|
||||
Assert.AreEqual(300, bank.Balance);
|
||||
Assert.AreEqual(2, inventory.OwnedModifiers.Count);
|
||||
Assert.AreEqual(300, _bank.Balance);
|
||||
Assert.AreEqual(2, _inventory.OwnedModifiers.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TryPurchase_FiresPurchaseEvent()
|
||||
{
|
||||
IShopItem purchased = null;
|
||||
shop.OnItemPurchased += item => purchased = item;
|
||||
_shop.OnItemPurchased += item => purchased = item;
|
||||
|
||||
var mod = CreateDef("test", shopPrice: 100);
|
||||
|
||||
shop.TryPurchase(mod);
|
||||
_shop.TryPurchase(mod);
|
||||
|
||||
Assert.IsNotNull(purchased);
|
||||
Assert.AreEqual("test", purchased.Id);
|
||||
@@ -117,16 +117,16 @@ namespace YachtDice.Tests
|
||||
{
|
||||
var mod = CreateDef("test", shopPrice: 100);
|
||||
|
||||
Assert.AreEqual(ShopItemState.Available, shop.GetItemState(mod));
|
||||
Assert.AreEqual(ShopItemState.Available, _shop.GetItemState(mod));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetItemState_TooExpensive_WhenCannotAfford()
|
||||
{
|
||||
bank.SetBalance(10);
|
||||
_bank.SetBalance(10);
|
||||
var mod = CreateDef("test", shopPrice: 100);
|
||||
|
||||
Assert.AreEqual(ShopItemState.TooExpensive, shop.GetItemState(mod));
|
||||
Assert.AreEqual(ShopItemState.TooExpensive, _shop.GetItemState(mod));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -134,9 +134,9 @@ namespace YachtDice.Tests
|
||||
{
|
||||
var mod = CreateDef("perm", shopPrice: 100);
|
||||
|
||||
shop.TryPurchase(mod);
|
||||
_shop.TryPurchase(mod);
|
||||
|
||||
Assert.AreEqual(ShopItemState.Owned, shop.GetItemState(mod));
|
||||
Assert.AreEqual(ShopItemState.Owned, _shop.GetItemState(mod));
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -144,11 +144,11 @@ namespace YachtDice.Tests
|
||||
{
|
||||
var die = DiceDefinition.CreateForTest<StandardDice>("test_die", shopPrice: 100);
|
||||
|
||||
bool result = shop.TryPurchase(die);
|
||||
bool result = _shop.TryPurchase(die);
|
||||
|
||||
Assert.IsTrue(result);
|
||||
Assert.AreEqual(400, bank.Balance);
|
||||
Assert.AreEqual(1, diceCollection.OwnedDice.Count);
|
||||
Assert.AreEqual(400, _bank.Balance);
|
||||
Assert.AreEqual(1, _diceCollection.OwnedDice.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -156,12 +156,12 @@ namespace YachtDice.Tests
|
||||
{
|
||||
var die = DiceDefinition.CreateForTest<StandardDice>("unique_die", shopPrice: 100);
|
||||
|
||||
shop.TryPurchase(die);
|
||||
bool secondResult = shop.TryPurchase(die);
|
||||
_shop.TryPurchase(die);
|
||||
bool secondResult = _shop.TryPurchase(die);
|
||||
|
||||
Assert.IsFalse(secondResult);
|
||||
Assert.AreEqual(400, bank.Balance);
|
||||
Assert.AreEqual(1, diceCollection.OwnedDice.Count);
|
||||
Assert.AreEqual(400, _bank.Balance);
|
||||
Assert.AreEqual(1, _diceCollection.OwnedDice.Count);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -169,9 +169,9 @@ namespace YachtDice.Tests
|
||||
{
|
||||
var die = DiceDefinition.CreateForTest<StandardDice>("die1", shopPrice: 50);
|
||||
|
||||
shop.TryPurchase(die);
|
||||
_shop.TryPurchase(die);
|
||||
|
||||
Assert.AreEqual(ShopItemState.Owned, shop.GetItemState(die));
|
||||
Assert.AreEqual(ShopItemState.Owned, _shop.GetItemState(die));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user