forked from LeadPipeSoftware/LeadPipe.Net
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GarageDoorShould.cs
97 lines (84 loc) · 2.95 KB
/
GarageDoorShould.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
// --------------------------------------------------------------------------------------------------------------------
// <copyright file="GarageDoorShould.cs" company="Lead Pipe Software">
// Copyright (c) Lead Pipe Software All rights reserved.
// </copyright>
// --------------------------------------------------------------------------------------------------------------------
using NUnit.Framework;
namespace LeadPipe.Net.Tests.FiniteStateMachineTests
{
/// <summary>
/// Tests using the sample GarageDoor and its states.
/// </summary>
[TestFixture]
public class GarageDoorShould
{
/// <summary>
/// The garage door.
/// </summary>
private GarageDoor door;
#region Public Methods
/// <summary>
/// Tests to make sure that the door's state changes to closed if it is open and the close method is called.
/// </summary>
[Test]
public void CloseGivenStateIsOpen()
{
// Act
this.door.Close();
// Assert
Assert.IsFalse(this.door.IsOpen, "The door should NOT be open, but claims that it is.");
Assert.IsTrue(this.door.IsClosed, "The door should be closed, but claims that it is not.");
Assert.IsFalse(this.door.IsLocked, "The door should NOT be locked, but claims that it is.");
}
/// <summary>
/// Tests to make sure that the door's state changes to open if it is closed and the open method is called.
/// </summary>
[Test]
public void OpenGivenStateIsClosed()
{
// Act
this.door.Close();
this.door.Open();
// Assert
Assert.IsTrue(this.door.IsOpen, "The door should be open, but claims that it is not.");
Assert.IsFalse(this.door.IsClosed, "The door should NOT be closed, but claims that it is.");
Assert.IsFalse(this.door.IsLocked, "The door should NOT be locked, but claims that it is.");
}
/// <summary>
/// Tests to make sure that the door's state changes to closed if it is open and the close method is called.
/// </summary>
[Test]
public void LockGivenStateIsOpen()
{
// Act
this.door.Lock();
// Assert
Assert.IsFalse(this.door.IsOpen, "The door should NOT be open, but claims that it is.");
Assert.IsTrue(this.door.IsClosed, "The door should be closed, but claims that it is not.");
Assert.IsTrue(this.door.IsLocked, "The door should be locked, but claims that it is not.");
}
/// <summary>
/// Tests to make sure that the door's state changes to closed if it is open and the close method is called.
/// </summary>
[Test]
public void LockGivenStateIsClosed()
{
// Act
this.door.Close();
this.door.Lock();
// Assert
Assert.IsFalse(this.door.IsOpen, "The door should NOT be open, but claims that it is.");
Assert.IsTrue(this.door.IsClosed, "The door should be closed, but claims that it is not.");
Assert.IsTrue(this.door.IsLocked, "The door should be locked, but claims that it is not.");
}
#endregion
/// <summary>
/// Runs before each test.
/// </summary>
[SetUp]
public void TestSetup()
{
this.door = new GarageDoor();
}
}
}