Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions src/Stateless/StateMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,7 @@ private void InternalFireOne(TTrigger trigger, params object[] args)
HandleReentryTrigger(args, representativeState, transition);
break;
}
#if TASKS
case DynamicTriggerBehaviourAsync asyncHandler:
{
asyncHandler.GetDestinationState(source, args)
Expand All @@ -434,6 +435,7 @@ private void InternalFireOne(TTrigger trigger, params object[] args)
});
break;
}
#endif
case DynamicTriggerBehaviour handler:
{
handler.GetDestinationState(source, args, out var destination);
Expand Down
10 changes: 6 additions & 4 deletions test/Stateless.Tests/DotGraphFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ public void DestinationStateIsDynamic()

Assert.Equal(expected, dotGraph);
}

#if TASKS
[Fact]
public void DestinationStateIsDynamicAsync()
{
Expand All @@ -299,7 +299,7 @@ public void DestinationStateIsDynamicAsync()

Assert.Equal(expected, dotGraph);
}

#endif
[Fact]
public void DestinationStateIsCalculatedBasedOnTriggerParameters()
{
Expand All @@ -321,6 +321,7 @@ public void DestinationStateIsCalculatedBasedOnTriggerParameters()
Assert.Equal(expected, dotGraph);
}

#if TASKS
[Fact]
public void DestinationStateIsCalculatedBasedOnTriggerParametersAsync()
{
Expand All @@ -341,6 +342,7 @@ public void DestinationStateIsCalculatedBasedOnTriggerParametersAsync()
#endif
Assert.Equal(expected, dotGraph);
}
#endif

[Fact]
public void OnEntryWithAnonymousActionAndDescription()
Expand Down Expand Up @@ -565,7 +567,7 @@ public void UmlWithDynamic()

Assert.Equal(expected, dotGraph);
}

#if TASKS
[Fact]
public void UmlWithDynamicAsync()
{
Expand Down Expand Up @@ -594,7 +596,7 @@ public void UmlWithDynamicAsync()

Assert.Equal(expected, dotGraph);
}

#endif
[Fact]
public void TransitionWithIgnoreAndEntry()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if TASKS
using System;
using System.Threading.Tasks;
using Xunit;

Expand Down Expand Up @@ -166,3 +167,4 @@ public async Task PermitDynamicIf_Permits_Reentry_When_GuardCondition_Met_Async(
}
}
}
#endif
4 changes: 3 additions & 1 deletion test/Stateless.Tests/DynamicAsyncTriggerBehaviourFixture.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if TASKS
using System;
using System.Threading.Tasks;
using Xunit;

Expand Down Expand Up @@ -166,3 +167,4 @@ public async void PermitDynamicIf_Permits_Reentry_When_GuardCondition_Met()
}
}
}
#endif
4 changes: 3 additions & 1 deletion test/Stateless.Tests/DynamicTriggerBehaviourAsyncFixture.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if TASKS
using System;
using System.Threading.Tasks;
using Xunit;

Expand Down Expand Up @@ -166,3 +167,4 @@ public async Task PermitDynamicIf_Permits_Reentry_When_GuardCondition_Met_Async(
}
}
}
#endif
4 changes: 3 additions & 1 deletion test/Stateless.Tests/GetInfoFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public void GetInfo_should_return_Entry_action_with_trigger_name()
Assert.Equal(Trigger.X.ToString(), entryActionInfo.FromTrigger);
}

#if TASKS
[Fact]
public void GetInfo_should_return_async_Entry_action_with_trigger_name()
{
Expand All @@ -38,5 +39,6 @@ public void GetInfo_should_return_async_Entry_action_with_trigger_name()
var entryActionInfo = Assert.Single(stateInfo.EntryActions);
Assert.Equal(Trigger.X.ToString(), entryActionInfo.FromTrigger);
}
#endif
}
}
}
4 changes: 3 additions & 1 deletion test/Stateless.Tests/InitialTransitionFixture.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if Task
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Xunit;
Expand Down Expand Up @@ -337,3 +338,4 @@ public async void AsyncTransitionEvents_OrderingWithInitialTransition()
}
}
}
#endif
6 changes: 4 additions & 2 deletions test/Stateless.Tests/InternalTransitionAsyncFixture.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#if Task
using System;
using System.Threading.Tasks;
using Xunit;

Expand Down Expand Up @@ -281,4 +282,5 @@ private class Order
public PaymentStatus PaymentStatus { get; internal set; }
}
}
}
}
#endif
2 changes: 2 additions & 0 deletions test/Stateless.Tests/InternalTransitionFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ public void OnlyOneHandlerExecuted()

Assert.Equal(2, handled);
}
#if Task
[Fact]
public async Task AsyncHandlesNonAsyndActionAsync()
{
Expand All @@ -287,5 +288,6 @@ public async Task AsyncHandlesNonAsyndActionAsync()

Assert.True(handled);
}
#endif
}
}
17 changes: 10 additions & 7 deletions test/Stateless.Tests/ReflectionFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public void DestinationStateIsDynamic_Binding()
Assert.Equal(0, trans.GuardConditionsMethodDescriptions.Count());
}
}

#if Task
[Fact]
public void DestinationStateIsDynamicAsync_Binding()
{
Expand Down Expand Up @@ -414,7 +414,8 @@ public void DestinationStateIsDynamicAsync_Binding()
Assert.Equal(0, trans.GuardConditionsMethodDescriptions.Count());
}
}

#endif

[Fact]
public void DestinationStateIsCalculatedBasedOnTriggerParameters_Binding()
{
Expand Down Expand Up @@ -449,6 +450,7 @@ public void DestinationStateIsCalculatedBasedOnTriggerParameters_Binding()
}
}

#if Task
[Fact]
public void DestinationStateIsCalculatedBasedOnTriggerParameters_BindingAsync()
{
Expand Down Expand Up @@ -482,7 +484,8 @@ public void DestinationStateIsCalculatedBasedOnTriggerParameters_BindingAsync()
Assert.Equal(0, trans.GuardConditionsMethodDescriptions.Count());
}
}

#endif

[Fact]
public void OnEntryWithAnonymousActionAndDescription_Binding()
{
Expand Down Expand Up @@ -816,7 +819,7 @@ public StateConfiguration OnEntryFrom<TArg0, TArg1>(TriggerWithParameters<TArg0,
public StateConfiguration OnEntryFrom<TArg0, TArg1, TArg2>(TriggerWithParameters<TArg0, TArg1, TArg2> trigger, Action<TArg0, TArg1, TArg2, Transition> entryAction, string entryActionDescription = null)
*/
}

#if Task
[Fact]
public void ReflectionMethodNamesAsync()
{
Expand Down Expand Up @@ -887,7 +890,7 @@ public StateConfiguration OnEntryFromAsync<TArg0, TArg1, TArg2>(TriggerWithParam
public StateConfiguration OnEntryFromAsync<TArg0, TArg1, TArg2>(TriggerWithParameters<TArg0, TArg1, TArg2> trigger, Func<TArg0, TArg1, TArg2, Transition, Task> entryAction, string entryActionDescription = null)
*/
}

#endif
State NextState()
{
return State.D;
Expand Down Expand Up @@ -959,7 +962,7 @@ StateConfiguration InternalPermit(TTrigger trigger, TState destinationState, str
StateConfiguration InternalPermitDynamic(TTrigger trigger, Func<object[], TState> destinationStateSelector, string guardDescription)
*/
}

#if Task
[Fact]
public void TransitionGuardNamesAsync()
{
Expand Down Expand Up @@ -1026,7 +1029,7 @@ StateConfiguration InternalPermit(TTrigger trigger, TState destinationState, str
StateConfiguration InternalPermitDynamic(TTrigger trigger, Func<object[], TState> destinationStateSelector, string guardDescription)
*/
}

#endif

[Fact]
public void InvocationInfo_Description_Property_When_Method_Name_Is_Null_Returns_String_Literal_Null()
Expand Down
5 changes: 5 additions & 0 deletions test/Stateless.Tests/StateMachineFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,7 @@ public void TransitionWhenPermitDyanmicIfHasMultipleExclusiveGuards()
Assert.Equal(sm.State, State.B);
}

#if Task
[Fact]
public async void TransitionWhenPermitDyanmicIfAsyncHasMultipleExclusiveGuards()
{
Expand All @@ -924,6 +925,7 @@ public async void TransitionWhenPermitDyanmicIfAsyncHasMultipleExclusiveGuards()
await sm.FireAsync(x, 3);
Assert.Equal(sm.State, State.B);
}
#endif

[Fact]
public void ExceptionWhenPermitDyanmicIfHasMultipleNonExclusiveGuards()
Expand All @@ -935,6 +937,8 @@ public void ExceptionWhenPermitDyanmicIfHasMultipleNonExclusiveGuards()

Assert.Throws<InvalidOperationException>(() => sm.Fire(x, 2));
}

#if Task
[Fact]
public void ExceptionWhenPermitDyanmicIfAsyncHasMultipleNonExclusiveGuards()
{
Expand All @@ -945,6 +949,7 @@ public void ExceptionWhenPermitDyanmicIfAsyncHasMultipleNonExclusiveGuards()

Assert.Throws<InvalidOperationException>(() => sm.Fire(x, 2));
}
#endif

[Fact]
public void TransitionWhenPermitIfHasMultipleExclusiveGuardsWithSuperStateTrue()
Expand Down
4 changes: 3 additions & 1 deletion test/Stateless.Tests/SynchronizationContextFixture.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#if TASKS
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
Expand Down Expand Up @@ -359,4 +360,5 @@ public void OnCompleted(Action continuation)
}
}
}
}
}
#endif
3 changes: 3 additions & 0 deletions test/Stateless.Tests/TriggerWithParametersFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public void StateParameterIsNotAmbiguous()
.PermitDynamicIf(pressTrigger, state => state);
}

#if TASKS

/// <summary>
/// issue #380 - default params on PermitIfDynamic lead to ambiguity at compile time... explicits work properly.
/// </summary>
Expand All @@ -75,6 +77,7 @@ public void StateParameterIsNotAmbiguousAsync()
fsm.Configure(State.A)
.PermitDynamicIfAsync(pressTrigger, state => Task.FromResult(state));
}
#endif

[Fact]
public void IncompatibleParameterListIsNotValid()
Expand Down