-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRevolverMock.cs
More file actions
31 lines (29 loc) · 947 Bytes
/
RevolverMock.cs
File metadata and controls
31 lines (29 loc) · 947 Bytes
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
namespace TJC.StateMachine.Tests.Mocks
{
internal class RevolverMock() : StateMachineBase<RevolverStates>(RevolverStates.Loaded)
{
public int BulletsLoaded { get; private set; } = 6;
public bool TryShoot()
{
switch (State)
{
case RevolverStates.Empty:
return false;
case RevolverStates.Loaded:
BulletsLoaded--;
if (BulletsLoaded == 0)
State = RevolverStates.Empty;
return true;
default:
throw new InvalidOperationException(
$"Unknown State [{State}] for method {nameof(TryShoot)}"
);
}
}
public void Reload()
{
BulletsLoaded = 6;
State = RevolverStates.Loaded;
}
}
}