StateBliss - fluent style finite state machine NuGet Package

Finite state machine with fluent syntax.

i.e.

public class DefineAuthenticationState2 : StateDefinition<AuthenticationState>
{
public override void Define(IStateFromBuilder<AuthenticationState> builder)
{
builder.From(AuthenticationState.Unauthenticated).To(AuthenticationState.Authenticated)
.Changing(this, a => a.ChangingHandler1);

}

private void ChangingHandler2(StateChangeGuardInfo<AuthenticationState> changeinfo)
{
var data = changeinfo.DataAs<Dictionary<string, object>>();
data["key2"] = "ChangingHandler2";
}
}

public class BasicTests //xUnit
{

public enum AuthenticationState
{
Unauthenticated,
Authenticated
}

[Fact]
public void Tests()
{
// Arrange
StateMachineManager.Register(new [] { typeof(BasicTests).Assembly }); //Register at bootstrap of your application, i.e. Startup
var currentState = AuthenticationState.Unauthenticated;
var data = new Dictionary<string, object>();

// Act
var changeInfo = StateMachineManager.Trigger(currentState, AuthenticationState.Authenticated, data);

// Assert
Assert.True(changeInfo.StateChangedSucceeded);
Assert.Equal("ChangingHandler1", changeInfo.Data["key1"]);
}
}.




Got any StateBliss - fluent style finite state machine Question?





Info

Version: 1.0.5
Author(s): Michael Cyril D. Magsuci
Last Update: Sunday, August 25, 2019
.NET Fiddle: Create the first Fiddle
Project Url: https://github.com/lingkodsoft/StateBliss
NuGet Url: https://www.nuget.org/packages/StateBliss


Install
Install-Package StateBliss
dotnet add package StateBliss
paket add StateBliss
StateBliss Download (Unzip the "nupkg" after downloading)

.NETStandard 2.0
  • No dependencies.
net471
  • No dependencies.
net472
  • No dependencies.
netcoreapp2.1
  • No dependencies.
netcoreapp2.2
  • No dependencies.


Tags



STATS

must-have-score

avg-downloads-per-day

0

days-since-last-release

1713