Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added failing test on conditional processing if "when" filter defined… #36

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 {}
}
}