本文整理汇总了C#中StateMachine.GetNewState方法的典型用法代码示例。如果您正苦于以下问题:C# StateMachine.GetNewState方法的具体用法?C# StateMachine.GetNewState怎么用?C# StateMachine.GetNewState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StateMachine
的用法示例。
在下文中一共展示了StateMachine.GetNewState方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Constructor_WhenCalled_CopiesTransitionTable
public void Constructor_WhenCalled_CopiesTransitionTable()
{
var transitionTable =
new List<Transition>
{
new Transition("Locked", "coin", "Unlocked")
};
var sut = new StateMachine(transitionTable);
transitionTable.Add(new Transition("Unlocked", "pass", "Locked"));
Assert.Throws<InvalidOperationException>(
() => sut.GetNewState("Unlocked", "pass"));
}
示例2: GetNewState_WhenTriggeringEventIsNull_Throws
public void GetNewState_WhenTriggeringEventIsNull_Throws()
{
var sut = new StateMachine(GetTestTransitionTable());
Assert.Throws<ArgumentNullException>(
() => sut.GetNewState("Locked", null));
}
示例3: GetNewState_WhenTerminalCurrentState_Throws
public void GetNewState_WhenTerminalCurrentState_Throws()
{
const string TerminalState = "Terminal";
const string TriggeringEvent = "ev";
var transitionTable =
new List<Transition>
{
new Transition("Whatever", TriggeringEvent, TerminalState)
};
var sut = new StateMachine(transitionTable);
Assert.Throws<InvalidOperationException>(
() => sut.GetNewState(TerminalState, TriggeringEvent));
}
示例4: GetNewState_WhenValidArguments_ReturnsNewState
public void GetNewState_WhenValidArguments_ReturnsNewState(
string currentState, string triggeringEvent, string expectedNewState)
{
var sut = new StateMachine(GetTestTransitionTable());
string result = sut.GetNewState(currentState, triggeringEvent);
Assert.Equal(expectedNewState, result);
}
示例5: GetNewState_WhenInvalidEvent_Throws
public void GetNewState_WhenInvalidEvent_Throws()
{
var sut = new StateMachine(GetTestTransitionTable());
Assert.Throws<InvalidOperationException>(
() => sut.GetNewState("Locked", "bogus"));
}
示例6: GetNewState_WhenInvalidCurrentState_Throws
public void GetNewState_WhenInvalidCurrentState_Throws()
{
var sut = new StateMachine(GetTestTransitionTable());
var ex = Assert.Throws<InvalidOperationException>(
() => sut.GetNewState("Bogus", "coin"));
Assert.Equal("Invalid state transition: state 'Bogus', event 'coin'.", ex.Message);
}
示例7: GetNewState_WhenCurrentStateIsNull_Throws
public void GetNewState_WhenCurrentStateIsNull_Throws()
{
var sut = new StateMachine(GetTestTransitionTable());
Assert.Throws<ArgumentNullException>(
() => sut.GetNewState(null, "coin"));
}