public void BeTrueWhenMissingStartStateOnDeclaratioWithEventOnEnterEvent() { //arrange var wf = new Floo(); wf.AddStateSetting("StartState") .IsStartState() .OnEnterEvent(FakeEnterExitCallback) .OnExitEvent(FakeEnterExitCallback); wf.AddStateSetting("EndState") .IsEndState() .OnEnterEvent(FakeEnterExitCallback); wf.AddTransition() .From("StartState") .On("Command") .GoTo("EndState"); //act var isValid = wf.IsValid(); //assert Assert.True(isValid); }
public void ThrowExceptionWhenSecondRuleMissingThirdEndState() { //arrange var wf = new Floo(); wf.AddTransition() .From("State") .On("Command") .GoTo("State"); wf.AddTransition() .From("OnState") .On("SendMessage") .Do(ctx => FakeFunk(ref ctx)) .When(FakeCheck) .GoTo("SentState") .When(FakeCheck) .GoTo("ErrorState") .Otherwise() //.StayAt("OnState") ; //act Action act = () => wf.Check(); //assert Assert.Throws <FloomeenException>(act); }
public void ReturnTrueWhenRule4IsValid() { //arrange var flow = new Floo(); flow.AddStateSetting("OnState").IsStartState(); flow.AddStateSetting("ErrorState").IsEndState(); flow.AddTransition() .From("OnState") .On("SendMessage") .Do(ctx => FakeFunk(ref ctx)) .When(FakeCheck) .GoTo("SentState") .When(FakeCheck) .GoTo("ErrorState") .Otherwise() .StayAt("OnState"); //act bool isValid = flow.IsValid(); //assert Assert.True(isValid); }
public void ThrowExceptionForInvalidSimpleDeclaration() { //arrange var wf = new Floo(); wf.AddStateSetting("State"); //act Action act = () => wf.Check(); //assert Assert.Throws <FloomeenException>(act); }
public void ThrowExceptionForInvalidSettingToStateDeclaration() { //arrange var wf = new Floo(); wf.AddStateSetting("EndState").IsStartState(); wf.AddTransition().From("State").On("Command").GoTo("EndState"); //act Action act = () => wf.Check(); //assert Assert.Throws <FloomeenException>(act); }
public void ThrowExceptionWhenMissingEndStateButOnSpecified() { //arrange var wf = new Floo(); wf.AddTransition() .From("OnState") .On("SendMessage"); //act Action act = () => wf.Check(); //assert Assert.Throws <FloomeenException>(act); }
public void ThrowExceptionWhenMissingConditions() { //arrange var wf = new Floo(); wf.AddTransition() .From("OnState") .On("SendMessage") .Do(ctx => FakeFunk(ref ctx)); //act Action act = () => wf.Check(); //assert Assert.Throws <FloomeenException>(act); }
public void ThrowExceptionWhenSameCommandRepeated() { //arrange var wf = new Floo(); wf.AddTransition() .From("OnState").On("Command").GoTo("State"); wf.AddTransition() .From("OnState").On("Command").GoTo("State"); //act Action act = () => wf.Check(); //assert Assert.Throws <FloomeenException>(act); }
public void BeTrueForStartStateDeclaration() { //arrange var wf = new Floo(); wf.AddStateSetting("StartState") .IsStartState(); wf.AddTransition() .From("StartState") .On("Command") .GoTo("EndState"); //act bool isValid = wf.IsValid(); //assert Assert.True(isValid); }
public void ReturnTrueWhenRule1IsValid() { //arrange var flow = new Floo(); flow.AddStateSetting("OnState").IsStartState(); flow.AddStateSetting("ErrorState").IsEndState(); flow.AddTransition() .From("OnState") .On("SendMessage") .GoTo("ErrorState"); //act bool isValid = flow.IsValid(); //assert Assert.True(isValid); }
protected MeenBase(string typename) { _machineName = string.IsNullOrEmpty(typename) ? GetType().FullName : typename; Flow = new Floo(_machineName); }