forked from foxguardsolutions/CodeCamp-MarsRover
-
Notifications
You must be signed in to change notification settings - Fork 0
/
RoverTest.cs
42 lines (34 loc) · 1.3 KB
/
RoverTest.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
using System;
namespace MarsRover
{
using NUnit.Framework;
[TestFixture]
public class RoverTest
{
[TestCase("FFLFF", 'E', 5, 6, 7, 5)]
[TestCase("FFFFFFFFFFFFFFFFFF", 'N', 9, 5, 9, 7)]
[TestCase("BBBRFF", 'S', 3, 1, 2, 8)]
[TestCase("FLFFFFLFRFFRFFRFFRF", 'W', 2, 3, 1, 7)]
public void TestMove(string movements, char direction, int startX, int startY, int finalX, int finalY)
{
Grid world = new Grid(10, 10);
Rover rover = new Rover(startX, startY, direction);
world.GridCellAt(3, 5).ContainsObstacle = true;
world.GridCellAt(3, 6).ContainsObstacle = true;
world.GridCellAt(1, 8).ContainsObstacle = true;
world.GridCellAt(7, 4).ContainsObstacle = true;
world.GridCellAt(6, 2).ContainsObstacle = true;
rover.World = world;
foreach (char movement in movements)
{
if (!rover.Move(movement))
{
break;
}
}
Console.WriteLine("Final Location: " + rover.CurrentLocation.X + " " + rover.CurrentLocation.Y);
Assert.AreEqual(finalX, rover.CurrentLocation.X);
Assert.AreEqual(finalY, rover.CurrentLocation.Y);
}
}
}