Skip to content

Commit

Permalink
Rename CurrentStateRecursive -> CurrentChildState
Browse files Browse the repository at this point in the history
  • Loading branch information
canton7 committed Aug 6, 2015
1 parent 9a00813 commit 91ecdcf
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
8 changes: 4 additions & 4 deletions src/StateMechanic/ChildStateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class ChildStateMachine : IStateMachine<State>, IEventDelegate, IStateDel
/// <summary>
/// If <see cref="CurrentState"/> has a child state machine, gets that child state machine's current state (recursively), otherwise gets <see cref="CurrentState"/>
/// </summary>
public State CurrentStateRecursive { get { return this.InnerStateMachine.CurrentStateRecursive; } }
public State CurrentChildState { get { return this.InnerStateMachine.CurrentChildState; } }

/// <summary>
/// Gets the initial state of this state machine
Expand All @@ -31,7 +31,7 @@ public class ChildStateMachine : IStateMachine<State>, IEventDelegate, IStateDel
public string Name { get { return this.InnerStateMachine.Name; } }

IState IStateMachine.CurrentState { get { return this.InnerStateMachine.CurrentState; } }
IState IStateMachine.CurrentStateRecursive { get { return this.InnerStateMachine.CurrentStateRecursive; } }
IState IStateMachine.CurrentChildState { get { return this.InnerStateMachine.CurrentChildState; } }
IState IStateMachine.InitialState { get { return this.InnerStateMachine.InitialState; } }

/// <summary>
Expand Down Expand Up @@ -173,7 +173,7 @@ public class ChildStateMachine<TStateData> : IStateMachine<State<TStateData>>, I
/// <summary>
/// If <see cref="CurrentState"/> has a child state machine, gets that child state machine's current state (recursively), otherwise gets <see cref="CurrentState"/>
/// </summary>
public State<TStateData> CurrentStateRecursive { get { return this.InnerStateMachine.CurrentStateRecursive; } }
public State<TStateData> CurrentChildState { get { return this.InnerStateMachine.CurrentChildState; } }

/// <summary>
/// Gets the initial state of this state machine
Expand All @@ -186,7 +186,7 @@ public class ChildStateMachine<TStateData> : IStateMachine<State<TStateData>>, I
public string Name { get { return this.InnerStateMachine.Name; } }

IState IStateMachine.CurrentState { get { return this.InnerStateMachine.CurrentState; } }
IState IStateMachine.CurrentStateRecursive { get { return this.InnerStateMachine.CurrentStateRecursive; } }
IState IStateMachine.CurrentChildState { get { return this.InnerStateMachine.CurrentChildState; } }
IState IStateMachine.InitialState { get { return this.InnerStateMachine.InitialState; } }

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions src/StateMechanic/IStateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public interface IStateMachine
/// <summary>
/// If <see cref="CurrentState"/> has a child state machine, gets that child state machine's current state (recursively), otherwise gets <see cref="CurrentState"/>
/// </summary>
IState CurrentStateRecursive { get; }
IState CurrentChildState { get; }

/// <summary>
/// Gets the initial state of this state machine
Expand Down Expand Up @@ -50,7 +50,7 @@ public interface IStateMachine

internal interface IStateMachine<TState> : IStateMachine, IEventDelegate where TState : class, IState<TState>
{
new TState CurrentStateRecursive { get; }
new TState CurrentChildState { get; }
new TState InitialState { get; }
new TState CurrentState { get; }
bool RequestEventFire(IEvent sourceEvent, Func<IState, bool> invoker, EventFireMethod eventFireMethod);
Expand Down
4 changes: 2 additions & 2 deletions src/StateMechanic/StateMachineInner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public TState CurrentState
}
}

public TState CurrentStateRecursive
public TState CurrentChildState
{
get
{
if (this.CurrentState != null && this.CurrentState.ChildStateMachine != null)
return this.CurrentState.ChildStateMachine.CurrentStateRecursive;
return this.CurrentState.ChildStateMachine.CurrentChildState;
else
return this.CurrentState;
}
Expand Down
6 changes: 3 additions & 3 deletions src/StateMechanicUnitTests/IntrospectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,15 @@ public void StateMachineReportsRecursiveCurrentStateCorrectly()
state1.TransitionOn(evt).To(state2);
state21.TransitionOn(evt).To(state22);

Assert.AreEqual(state1, stateMachine.CurrentStateRecursive);
Assert.AreEqual(state1, stateMachine.CurrentChildState);

evt.Fire();

Assert.AreEqual(state21, stateMachine.CurrentStateRecursive);
Assert.AreEqual(state21, stateMachine.CurrentChildState);

evt.Fire();

Assert.AreEqual(state22, stateMachine.CurrentStateRecursive);
Assert.AreEqual(state22, stateMachine.CurrentChildState);
}

[Test]
Expand Down
10 changes: 5 additions & 5 deletions src/StateMechanicUnitTests/StateMachineStateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void CurrentStateReflectsCurrentState()
}

[Test]
public void CurrentStateRecursiveReflectsCurrentStateOfChild()
public void CurrentChildStateReflectsCurrentStateOfChild()
{
var sm = new StateMachine("state machine");
var initialState = sm.CreateInitialState("initial state");
Expand All @@ -55,19 +55,19 @@ public void CurrentStateRecursiveReflectsCurrentStateOfChild()
childInitialState.TransitionOn(evt).To(childState1);
state1.TransitionOn(evt2).To(initialState);

Assert.AreEqual(initialState, sm.CurrentStateRecursive);
Assert.AreEqual(initialState, sm.CurrentChildState);

evt.Fire();

Assert.AreEqual(childInitialState, sm.CurrentStateRecursive);
Assert.AreEqual(childInitialState, sm.CurrentChildState);

evt.Fire();

Assert.AreEqual(childState1, sm.CurrentStateRecursive);
Assert.AreEqual(childState1, sm.CurrentChildState);

evt2.Fire();

Assert.AreEqual(initialState, sm.CurrentStateRecursive);
Assert.AreEqual(initialState, sm.CurrentChildState);
}

[Test]
Expand Down

0 comments on commit 91ecdcf

Please sign in to comment.