From 7e0ddceb2c5e5f095da1557d26107187245c4cf9 Mon Sep 17 00:00:00 2001 From: Malachy Byrne Date: Fri, 14 Jun 2024 23:43:42 +0100 Subject: [PATCH] 100% test coverage baybee --- .../proficiencies/ArmorProficiencyTest.cs | 38 +++++++++++++++++++ pflib-net/characters/PlayerCharacter.cs | 4 +- pflib-net/characters/internals/stats/Stats.cs | 2 +- 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 pflib-net.Tests/characters/internals/proficiencies/ArmorProficiencyTest.cs diff --git a/pflib-net.Tests/characters/internals/proficiencies/ArmorProficiencyTest.cs b/pflib-net.Tests/characters/internals/proficiencies/ArmorProficiencyTest.cs new file mode 100644 index 0000000..a905a1e --- /dev/null +++ b/pflib-net.Tests/characters/internals/proficiencies/ArmorProficiencyTest.cs @@ -0,0 +1,38 @@ +using System.Collections.Generic; +using NUnit.Framework; +using pflib_net.characters.internals.proficiencies; + +namespace pflib_net.Tests.characters.internals.proficiencies; + +[TestFixture] +[TestOf(typeof(ArmorProficiency))] +public class ArmorProficiencyTest +{ + private Dictionary _values = new() + { + { ProficiencyType.Unarmored, 0}, + { ProficiencyType.LightArmor, 5 }, + { ProficiencyType.MediumArmor, 7 }, + { ProficiencyType.HeavyArmor, 9 } + }; + + private Dictionary _proficiencyValues = + new() + { + { ProficiencyType.Unarmored, ProficiencyValue.None }, + { ProficiencyType.LightArmor, ProficiencyValue.Trained }, + { ProficiencyType.MediumArmor, ProficiencyValue.Expert }, + { ProficiencyType.HeavyArmor, ProficiencyValue.Master } + }; + + [Test] + [TestCase(ProficiencyType.Unarmored)] + [TestCase(ProficiencyType.LightArmor)] + [TestCase(ProficiencyType.MediumArmor)] + [TestCase(ProficiencyType.HeavyArmor)] + public void GetValueReturnsCorrectAc(ProficiencyType type) + { + var armorProficiency = new ArmorProficiency(_proficiencyValues); + Assert.That(armorProficiency.GetValue(type, 3), Is.EqualTo(_values[type])); + } +} \ No newline at end of file diff --git a/pflib-net/characters/PlayerCharacter.cs b/pflib-net/characters/PlayerCharacter.cs index 16c17a3..7fd28ea 100644 --- a/pflib-net/characters/PlayerCharacter.cs +++ b/pflib-net/characters/PlayerCharacter.cs @@ -10,8 +10,8 @@ public class PlayerCharacter : ICharacter private int Hp { get; set; } private Stats Stats { get; set; } private int Level { get; set; } - private ArmorProficiency ArmorProficiency { get; set; } - private HashSet Conditions { get; set; } = new HashSet(); + private ArmorProficiency ArmorProficiency { get; } + private HashSet _conditions = new(); public PlayerCharacter(int hp, Stats stats, int level, ArmorProficiency armorProficiency) { diff --git a/pflib-net/characters/internals/stats/Stats.cs b/pflib-net/characters/internals/stats/Stats.cs index 11ef3c6..1939ad4 100644 --- a/pflib-net/characters/internals/stats/Stats.cs +++ b/pflib-net/characters/internals/stats/Stats.cs @@ -4,7 +4,7 @@ namespace pflib_net.characters.internals.stats; public class Stats { - private Dictionary StatDict { get; set; } = new(); + private Dictionary StatDict { get; } = new(); public Stats(int strength, int dexterity, int constitution, int intelligence, int wisdom, int charisma) {