forked from foxguardsolutions/CodeCamp-Bowling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RollTests.cs
77 lines (67 loc) · 1.85 KB
/
RollTests.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
namespace BowlingKata
{
using NUnit.Framework;
[TestFixture]
public class RollTests
{
[SetUp]
public void Init()
{
Roll.AllowedValues = "-123456789/X";
}
[Test]
public void ConstructorInitializesToZero()
{
Roll r1 = new Roll();
Assert.AreEqual('-', r1.Value);
}
[Test]
public void ConstructorSetsValueToParameter()
{
Roll r1 = new Roll('1');
Assert.AreEqual('1', r1.Value);
}
[Test]
public void ToIntValueConvertsArbitraryStrNumberToInt()
{
Roll r1 = new Roll('4');
Assert.AreEqual(4, r1.ToIntValue());
}
[Test]
public void ToIntValueConvertsSpareTo10()
{
Roll r1 = new Roll('/');
Assert.AreEqual(10, r1.ToIntValue());
}
[Test]
public void ToIntValueConvertsStrikeTo11()
{
Roll r1 = new Roll('X');
Assert.AreEqual(11, r1.ToIntValue());
}
public void ToIntValueConvertsHyphenToZero()
{
Roll r1 = new Roll('-');
Assert.AreEqual(0, r1.ToIntValue());
}
[Test]
[ExpectedException(typeof(System.ArgumentOutOfRangeException))]
public void ConstructorDoesNotAllowInvalidValues()
{
Roll r1 = new Roll('f');
}
[Test]
public void RollsMayBeAdded()
{
Roll r1 = new Roll('5');
Roll r2 = new Roll('4');
Assert.AreEqual(9, r1 + r2);
}
[Test]
public void RollsExplicitlyConvertedToIntegers()
{
Roll r1 = new Roll('5');
Assert.AreEqual(5, (int)r1);
}
}
}