Skip to content

Commit

Permalink
Added failing test on conditional processing if "when" filter defined…
Browse files Browse the repository at this point in the history
… and evaluates to true
  • Loading branch information
Ushenko Dmitry authored and phatboyg committed Nov 20, 2017
1 parent c444f36 commit 8e4d03b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/Automatonymous.Tests/Condition_Specs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ public async Task Should_work()
Assert.That(_instance.CurrentState, Is.EqualTo(_machine.Running));
}

[Test]
public async Task Should_allow_if_condition_to_be_evaluated()
{
await _machine.RaiseEvent(_instance, _machine.ExplicitFilterStarted, new StartedExplicitFilter());

Assert.That(_instance.CurrentState, Is.Not.EqualTo(_machine.ShouldNotBeHere));
}

[SetUp]
public void Specifying_an_event_activity()
{
Expand Down Expand Up @@ -65,6 +73,13 @@ public InstanceStateMachine()
.If(context => context.Data.InitializeOnly, x => x.Then(context => Console.WriteLine("Initializing Only!")))
.TransitionTo(Initialized));

During(Initial,
When(ExplicitFilterStarted, context => true)
.If(context => false, binder =>
binder.Then(context => Console.WriteLine("Should not be here!"))
.TransitionTo(ShouldNotBeHere))
.If(context => true, binder => binder.Then(context => Console.WriteLine("Initializing Only!"))));

During(Running,
When(Finish)
.Finalize());
Expand All @@ -74,8 +89,11 @@ public InstanceStateMachine()

public State Running { get; private set; }
public State Initialized { get; private set; }
public State ShouldNotBeHere { get; private set; }

public Event<Start> Started { get; private set; }
public Event<StartedExplicitFilter> ExplicitFilterStarted { get; private set; }

public Event Finish { get; private set; }
}

Expand All @@ -84,5 +102,8 @@ class Start
{
public bool InitializeOnly { get; set; }
}


class StartedExplicitFilter {}
}
}

0 comments on commit 8e4d03b

Please sign in to comment.