public void state_controller_build_fails_without_default_state()
 {
     Assert.Throws <InvalidOperationException>(() => builder.Build());
     Assert.Throws <InvalidOperationException>(() => builder.Build());
     builder.WithDefaultState(new TestState());
     nonEmptyBuilder.WithDefaultState(new TestState());
     Assert.DoesNotThrow(() => builder.Build());
     Assert.DoesNotThrow(() => builder.Build());
 }
예제 #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();
        }