public void FluentStateMachineBuilder_Initiates_NotCurrentlyDefiningState_ThrowsTriggerEx()
        {
            var builder = new FluentStateMachineBuilder <StubStateModel>();

            Assert.Throws <FluentSyntaxException>(() =>
                                                  builder.Initiates());
        }
        public void FluentStateMachineBuilder_On_NotCurrentlyDefiningTransition_ThrowsFluentSyntaxException()
        {
            var builder = new FluentStateMachineBuilder <StubStateModel>();

            Assert.Throws <FluentSyntaxException>(() =>
                                                  builder.On("s"));
        }
        public void FluentStateMachineBuilder_Compile_NoStatements_ThrowsFluentSyntaxEx()
        {
            var builder = new FluentStateMachineBuilder <StubStateModel>();

            Assert.Throws <FluentSyntaxException>(() =>
                                                  builder.Compile());
        }
        public void FluentStateMachineBuilder_When_WhileNotDefTrans_ThrowsFluentSyntaxEx()
        {
            var builder = new FluentStateMachineBuilder <StubStateModel>();

            builder.State("s1", null);
            // shouldn't allow guard definition while not even defining a transition
            Assert.Throws <FluentSyntaxException>(() =>
                                                  builder.When(m => false));
        }
 public void FluentStateMachineBuilder_AfterEntry_NotDefiningState_ThrowsFluentSyntaxException()
 {
     var builder = new FluentStateMachineBuilder<StubStateModel>();
     builder.State("s1", null);
     builder.TransitionsTo("s2");
     // should nto allow After Exit definition while in middle of defining a transition
     Assert.Throws<FluentSyntaxException>(() =>
         builder.AfterEntry(e => { }));
 }
        public void FluentStateMachineBuilder_CompileConfig_NullConfig_ThrowsNullEx()
        {
            var builder = new FluentStateMachineBuilder <StubStateModel>();

            builder.State("s1", null);
            builder.Initiates();
            Assert.Throws <ArgumentNullException>(() =>
                                                  builder.Compile(null));
        }
        public void FluentStateMachineBuilder_TransitionsTo_WhileAlreadyBuildingTransition_ThrowsFluentSyntaxEx()
        {
            var builder = new FluentStateMachineBuilder <StubStateModel>();

            builder.State("s1", null);
            builder.TransitionsTo("s2");
            // shouldn't allow another definition of transition while in middle of transition definition
            Assert.Throws <FluentSyntaxException>(() =>
                                                  builder.TransitionsTo("s3"));
        }
        public void FluentStateMachineBuilder_State_DefiningTransition_ThrowsFluentSyntaxException()
        {
            var builder = new FluentStateMachineBuilder <StubStateModel>();

            builder.State("s1", null);
            builder.TransitionsTo("t1");
            // shouldn't allow new state definitions while in middle of defining a transition
            Assert.Throws <FluentSyntaxException>(() =>
                                                  builder.State("s2", null));
        }
        public void FluentStateMachineBuilder_AfterExit_NotDefiningState_ThrowsFluentSyntaxException()
        {
            var builder = new FluentStateMachineBuilder <StubStateModel>();

            builder.State("s1", null);
            builder.TransitionsTo("s2");
            // should nto allow After Exit definition while in middle of defining a transition
            Assert.Throws <FluentSyntaxException>(() =>
                                                  builder.AfterExit(e => { }));
        }
Exemplo n.º 10
0
        public void FluentStateMachineBuilder_Compile_ReturnsNewStateMachineWithDefinedParts()
        {
            var builder = new FluentStateMachineBuilder <StubStateModel>();

            builder.State("s1", null);
            builder.Initiates();
            var machine = builder.Compile();

            Assert.NotNull(machine);
            Assert.Equal("s1", machine.InitialState.ToString());
        }
Exemplo n.º 11
0
        public void FluentStateMachineBuilder_CompileConfig_ReturnsNewStateMachineWithDefinedParts_WithConfig()
        {
            var builder = new FluentStateMachineBuilder <StubStateModel>();

            builder.State("s1", null);
            builder.Initiates();
            var config = new StateMachineConfiguration {
                RaiseExceptionBeforeTransitionToSameState = true
            };
            var machine = builder.Compile(config);

            Assert.NotNull(machine);
            Assert.Same(config, machine.Configuration);
            Assert.Equal(true, machine.Configuration.RaiseExceptionBeforeTransitionToSameState);
        }
 public void FluentStateMachineBuilder_When_WhileNotDefTrans_ThrowsFluentSyntaxEx()
 {
     var builder = new FluentStateMachineBuilder<StubStateModel>();
     builder.State("s1", null);
     // shouldn't allow guard definition while not even defining a transition
     Assert.Throws<FluentSyntaxException>(() =>
         builder.When(m => false));
 }
 public void FluentStateMachineBuilder_Compile_NoStatements_ThrowsFluentSyntaxEx()
 {
     var builder = new FluentStateMachineBuilder<StubStateModel>();
     Assert.Throws<FluentSyntaxException>(() =>
         builder.Compile());
 }
 public void FluentStateMachineBuilder_Compile_ReturnsNewStateMachineWithDefinedParts()
 {
     var builder = new FluentStateMachineBuilder<StubStateModel>();
     builder.State("s1", null);
     builder.Initiates();
     var machine = builder.Compile();
     Assert.NotNull(machine);
     Assert.Equal("s1", machine.InitialState.ToString());
 }
        public void FluentStateMachineBuilder_CompileConfig_ReturnsNewStateMachineWithDefinedParts_WithConfig()
        {
            var builder = new FluentStateMachineBuilder<StubStateModel>();
            builder.State("s1", null);
            builder.Initiates();
            var config = new StateMachineConfiguration { RaiseExceptionBeforeTransitionToSameState = true };
            var machine = builder.Compile(config);

            Assert.NotNull(machine);
            Assert.Same(config, machine.Configuration);
            Assert.Equal(true, machine.Configuration.RaiseExceptionBeforeTransitionToSameState);
        }
 public void FluentStateMachineBuilder_TransitionsTo_WhileAlreadyBuildingTransition_ThrowsFluentSyntaxEx()
 {
     var builder = new FluentStateMachineBuilder<StubStateModel>();
     builder.State("s1",null);
     builder.TransitionsTo("s2");
     // shouldn't allow another definition of transition while in middle of transition definition
     Assert.Throws<FluentSyntaxException>(() =>
         builder.TransitionsTo("s3"));
 }
 public void FluentStateMachineBuilder_State_DefiningTransition_ThrowsFluentSyntaxException()
 {
     var builder = new FluentStateMachineBuilder<StubStateModel>();
     builder.State("s1", null);
     builder.TransitionsTo("t1");
     // shouldn't allow new state definitions while in middle of defining a transition
     Assert.Throws<FluentSyntaxException>(() =>
         builder.State("s2", null));
 }
 public void FluentStateMachineBuilder_On_NotCurrentlyDefiningTransition_ThrowsFluentSyntaxException()
 {
     var builder = new FluentStateMachineBuilder<StubStateModel>();
     Assert.Throws<FluentSyntaxException>(() =>
         builder.On("s"));
 }
 public void FluentStateMachineBuilder_Initiates_NotCurrentlyDefiningState_ThrowsTriggerEx()
 {
     var builder = new FluentStateMachineBuilder<StubStateModel>();
     Assert.Throws<FluentSyntaxException>(() =>
         builder.Initiates());
 }
Exemplo n.º 20
0
        public static InitialFluentBuilderApi <TStateModel> Describe()
        {
            var builder = new FluentStateMachineBuilder <TStateModel>();

            return(new InitialFluentBuilderApi <TStateModel>(builder));
        }
 public void FluentStateMachineBuilder_CompileConfig_NullConfig_ThrowsNullEx()
 {
     var builder = new FluentStateMachineBuilder<StubStateModel>();
     builder.State("s1", null);
     builder.Initiates();
     Assert.Throws<ArgumentNullException>(() =>
         builder.Compile(null));
 }