-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUnitTest.cs
More file actions
110 lines (101 loc) · 3.16 KB
/
UnitTest.cs
File metadata and controls
110 lines (101 loc) · 3.16 KB
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
namespace TurtleChallenge;
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMovementShouldPass()
{
Direction dir = Direction.UP;
Turtle turtle = new (dir, 0, 0);
Board board = new (1, 3, turtle, [], [0,2]); //Creates Board with 1 height and 2 width, where exit is placed on [0,2]
MoveResult move = board.Move();
Assert.AreEqual(move, MoveResult.MOVE);
}
[TestMethod]
public void TestMovementShouldFail()
{
Direction dir = Direction.UP;
Turtle turtle = new (dir, 0, 0);
Board board = new (2, 1, turtle, [], [1, 0]); //Creates Board with 1 height and 2 width, where exit is placed on [1,0]
MoveResult move = board.Move();
Assert.AreEqual(move, MoveResult.CANT);
}
[TestMethod]
public void TestMovementShouldExit()
{
Direction dir = Direction.UP;
Turtle turtle = new (dir, 0, 0);
Board board = new (1, 2, turtle, [], [0,1]); //Creates Board with 2 height and 1 width, where exit is placed on [0,1]
MoveResult move = board.Move();
Assert.AreEqual(move, MoveResult.EXIT);
}
[TestMethod]
public void TestMovementShouldMine()
{
Direction dir = Direction.UP;
Turtle turtle = new (dir, 0, 0);
Board board = new (1, 3, turtle, [0,1], [0,2]); //Creates Board with 3 height and 1 width, where mine is placed on [0,1]
MoveResult move = board.Move();
Assert.AreEqual(move, MoveResult.MINE);
}
[TestMethod]
public void TestPlacingExitOut()
{
try{
Direction dir = Direction.UP;
Turtle turtle = new (dir, 0, 0);
Board board = new (2, 1, turtle, [], [4, 0]);
} catch (IndexOutOfRangeException) {
return;
}
Assert.Fail("Not thrown exception");
}
[TestMethod]
public void TestPlacingTurtleOut()
{
try{
Direction dir = Direction.UP;
Turtle turtle = new (dir, 5, 5);
Board board = new (2, 1, turtle, [], [0, 0]);
} catch (IndexOutOfRangeException) {
return;
}
Assert.Fail("Not thrown exception");
}
[TestMethod]
public void TestPlacingMineOut()
{
try{
Direction dir = Direction.UP;
Turtle turtle = new (dir, 1, 0);
Board board = new (2, 1, turtle, [4,0], [0, 0]);
} catch (IndexOutOfRangeException) {
return;
}
Assert.Fail("Not thrown exception");
}
[TestMethod]
public void TestTurtleOverlapping()
{
try{
Direction dir = Direction.UP;
Turtle turtle = new (dir, 0, 0);
Board board = new (5, 5, turtle, [], [0, 0]);
} catch (OverlapException) {
return;
}
Assert.Fail("Not thrown exception");
}
[TestMethod]
public void TestMineOverlapping()
{
try{
Direction dir = Direction.UP;
Turtle turtle = new (dir, 0, 0);
Board board = new (5, 5, turtle, [1,1], [1, 1]);
} catch (OverlapException) {
return;
}
Assert.Fail("Not thrown exception");
}
}