-
Notifications
You must be signed in to change notification settings - Fork 0
/
InstructionsTests.cs
59 lines (53 loc) · 1.48 KB
/
InstructionsTests.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
using System;
using NUnit.Framework;
using LawnMowerLib;
namespace LawnMower
{
[TestFixture]
public class InstructionsTests
{
private Instructions instructions;
private char[] chars;
[SetUp]
public void Setup()
{
chars = new[]{ 'L', 'M', 'R', 'M' };
instructions = new Instructions(chars);
}
[Test]
public void InstructionsInitialiseCurrentWithDefaultValue()
{
Assert.AreEqual(default(char), instructions.Current);
}
[Test]
public void InstructionsMoveNext()
{
for(var i=0; i<chars.Length; i++)
{
instructions.MoveNext();
Assert.AreEqual(chars[i], instructions.Current);
}
}
[Test]
public void InstructionsMoveNextStopsOnTheLastItem()
{
bool moreElements = false;
for(var i=0; i<instructions.Length+1; i++)
{
moreElements = instructions.MoveNext();
}
Assert.IsFalse(moreElements);
Assert.AreEqual(chars[instructions.Length-1], instructions.Current);
}
[Test]
public void InstructionsResetWorks()
{
for(var i=0; i<instructions.Length; i++)
{
instructions.MoveNext();
}
instructions.Reset();
Assert.AreEqual(default(char), instructions.Current);
}
}
}