public void Setup()
 {
     _state          = new TestState();
     builder         = new StateControllerBuilder <TestState, TestContext>();
     nonEmptyBuilder = new StateControllerBuilder <TestState, TestContext>();
     nonEmptyBuilder.AddState(_state);
 }
Exemple #2
0
        public void Setup()
        {
            var builder =
                new StateControllerBuilder <TestState, TestContext>()
                .WithDefaultState(A)
                .AddState(B)
                .AddState(C)
                .AddState(D)
                .AddState(E)
                .AddState(F);

            A.AddTransition(B, ctx => ctx.B > 10);
            A.AddTransition(C, ctx => ctx.C > 10);
            B.AddTransition(C, ctx => ctx.B > 20);
            B.AddTransition(D, ctx => ctx.C > 20);
            C.AddTransition(D, ctx => ctx.B > 30);
            C.AddTransition(E, ctx => ctx.C > 30);
            D.AddTransition(E, ctx => ctx.B > 40);
            D.AddTransition(F, ctx => ctx.C > 40);
            E.AddTransition(F, ctx => ctx.B > 50);
            E.AddTransition(A, ctx => ctx.C > 50);
            F.AddTransition(A, ctx => ctx.B > 50);
            F.AddTransition(B, ctx => ctx.C > 50);
            new[] { B, C, D, E, F }.AddTransitions(A, ctx => ctx.A);
            _controller = builder.Build();
        }
 internal StateController(StateControllerBuilder <T, TContext> builder)
 {
     DefaultState = builder.DefaultState;
     CurrentState = DefaultState;
     _states      = builder._states;
     States       = new ReadOnlyCollection <T>(builder.States.ToArray());
 }