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)
Dependencies
.NETStandard 2.0
No dependencies.
No dependencies.
No dependencies.
No dependencies.
No dependencies.
Tags
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"]);
}
}.