-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArmorTests.cs
150 lines (128 loc) · 3.71 KB
/
ArmorTests.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TDnD;
namespace TDnDTests
{
[TestClass]
public class LeatherArmorTests
{
private ICharacter _character;
[TestInitialize]
public void Initialize()
{
_character = new BaseCharacter();
}
[TestMethod]
public void GivesPlusTwoArmorClass()
{
_character.Armor = new LeatherArmor();
Assert.AreEqual(12, _character.GetArmorClass());
}
}
[TestClass]
public class PlateArmorTests
{
private ICharacter _character;
[TestInitialize]
public void Initialize()
{
_character = new BaseCharacter();
}
[TestMethod]
public void GivesEightBonusArmor()
{
_character = new Dwarf(_character) { Armor = new PlateArmor(_character) };
Assert.AreEqual(18, _character.GetArmorClass());
}
[TestMethod]
[ExpectedException(typeof(ArgumentException),
"Only Fighters and Dwarves can equip Plate")]
public void CannotBeWornByMany()
{
_character.Armor = new PlateArmor(_character);
}
[TestMethod]
public void CanBeWornByFighters()
{
_character = new Fighter(_character) { Armor = new PlateArmor(_character) };
Assert.AreEqual(18, _character.GetArmorClass());
}
}
[TestClass]
public class DamageReductionLeatherArmorTests
{
private ICharacter _character;
private ICharacter _strongEnemy;
[TestInitialize]
public void Initialize()
{
_character = new Dwarf(new BaseCharacter()) { Armor = new DamageReduction(2, new LeatherArmor()) };
var abilities = new AbilityScores(20);
_strongEnemy = new BaseCharacter(abilities);
}
[TestMethod]
public void StillGivesTwoAc()
{
Assert.AreEqual(12, _character.GetArmorClass());
}
[TestMethod]
public void GivesTwoDamageReduction()
{
_strongEnemy.Attack(18, _character);
Assert.AreEqual(4, _character.CurrentDamage);
}
}
[TestClass]
public class ChainMailTests
{
private ICharacter _character;
[TestInitialize]
public void Initialize()
{
_character = new BaseCharacter();
}
[TestMethod]
public void GivesFiveToAc()
{
_character.Armor = new ChainMail();
Assert.AreEqual(15, _character.GetArmorClass());
}
}
[TestClass]
public class ElvenChainMailTests
{
private ICharacter _character;
private ICharacter _enemy;
[TestInitialize]
public void Initialize()
{
_character = new BaseCharacter();
_character.Armor = new ElvenArmor(new ChainMail(), _character);
_enemy = new BaseCharacter();
}
[TestMethod]
public void NoExtraBonusToNonElves()
{
Assert.AreEqual(15, _character.GetArmorClass());
}
[TestMethod]
public void ThreeExtraBonusToElves()
{
_character = new Elf(_character);
Assert.AreEqual(18, _character.GetArmorClass());
}
[TestMethod]
public void NoBonusAttackToNonElves()
{
var hit = _character.Attack(10, _enemy);
Assert.IsFalse(hit);
}
[TestMethod]
public void OneBonusAttackToElves()
{
_character = new Elf(_character);
var hit = _character.Attack(10, _enemy);
Assert.IsTrue(hit);
}
}
}