diff --git a/src/Stateless/StateMachine.Async.cs b/src/Stateless/StateMachine.Async.cs index c4e61e98..846842a5 100644 --- a/src/Stateless/StateMachine.Async.cs +++ b/src/Stateless/StateMachine.Async.cs @@ -46,6 +46,19 @@ public Task FireAsync(TTrigger trigger) return InternalFireAsync(trigger, new object[0]); } + /// + /// Transition from the current state via the specified trigger in async fashion. + /// The target state is determined by the configuration of the current state. + /// Actions associated with leaving the current state and entering the new one + /// will be invoked. + /// + /// The trigger to fire. + /// A variable-length parameters list containing arguments. + public Task FireAsync(TTrigger trigger, params object[] args) + { + return InternalFireAsync(trigger, args); + } + /// /// Transition from the current state via the specified trigger in async fashion. /// The target state is determined by the configuration of the current state. diff --git a/test/Stateless.Tests/AsyncActionsFixture.cs b/test/Stateless.Tests/AsyncActionsFixture.cs index 79ff95f5..e74d3e76 100644 --- a/test/Stateless.Tests/AsyncActionsFixture.cs +++ b/test/Stateless.Tests/AsyncActionsFixture.cs @@ -541,6 +541,29 @@ public async Task OnEntryFromAsync_WhenEnteringByAnotherTrigger_InvokesAction() Assert.False(wasInvoked); } + [Fact] + public async Task FireAsyncTriggerWithParametersArray() + { + const string expectedParam = "42-Stateless-True-420.69-Y"; + string actualParam = null; + + var sm = new StateMachine(State.A); + + sm.Configure(State.A) + .Permit(Trigger.X, State.B); + + sm.Configure(State.B) + .OnEntryAsync(t => + { + actualParam = string.Join("-", t.Parameters); + return Task.CompletedTask; + }); + + await sm.FireAsync(Trigger.X, 42, "Stateless", true, 420.69, Trigger.Y); + + Assert.Equal(expectedParam, actualParam); + } + [Fact] public async Task FireAsync_TriggerWithMoreThanThreeParameters() {