Esempio n. 1
0
        public void ParallelStateWithCatchers()
        {
            var stateMachine = StateMachineBuilder.StateMachine()
                               .StartAt("InitialState")
                               .State("InitialState", StateMachineBuilder.ParallelState()
                                      .Transition(StateMachineBuilder.End())
                                      .Branches(
                                          StateMachineBuilder.SubStateMachine()
                                          .Comment("Branch one")
                                          .StartAt("BranchOneInitial")
                                          .State("BranchOneInitial", StateMachineBuilder.SucceedState()),
                                          StateMachineBuilder.SubStateMachine()
                                          .Comment("Branch two")
                                          .StartAt("BranchTwoInitial")
                                          .State("BranchTwoInitial", StateMachineBuilder.SucceedState())
                                          )
                                      .Catchers(StateMachineBuilder.Catcher()
                                                .ErrorEquals("Foo", "Bar")
                                                .Transition(StateMachineBuilder.Next("RecoveryState"))
                                                .ResultPath("$.result"),
                                                StateMachineBuilder.Catcher()
                                                .CatchAll()
                                                .Transition(StateMachineBuilder.Next("OtherRecoveryState"))
                                                .ResultPath("$.result")
                                                ))
                               .State("RecoveryState", StateMachineBuilder.SucceedState())
                               .State("OtherRecoveryState", StateMachineBuilder.SucceedState())
                               .Build();

            AssertStateMachine(stateMachine, "ParallelStateWithCatchers.json");
        }
Esempio n. 2
0
 public void CatcherInTaskState_InvalidTransition_IsNotValid()
 {
     Assert.Throws <ValidationException>(() =>
                                         StateMachineBuilder.StateMachine()
                                         .StartAt("Initial")
                                         .State("Initial", StateMachineBuilder.TaskState()
                                                .Transition(StateMachineBuilder.End())
                                                .Catcher(StateMachineBuilder.Catcher()
                                                         .Transition(StateMachineBuilder.Next("NoSuchState"))
                                                         .CatchAll())
                                                .Resource("arn"))
                                         .Build());
 }
Esempio n. 3
0
 [Fact] //
 public void CatcherInTaskState_ValidTransition_IsValid()
 {
     StateMachineBuilder.StateMachine()
     .StartAt("Initial")
     .State("Initial", StateMachineBuilder.TaskState()
            .Transition(StateMachineBuilder.End())
            .Catcher(StateMachineBuilder.Catcher()
                     .Transition(StateMachineBuilder.Next("Terminal"))
                     .CatchAll())
            .Resource("arn"))
     .State("Terminal", StateMachineBuilder.SucceedState())
     .Build();
 }
Esempio n. 4
0
 public void ParallelStateInvalidCatcher_IsNotValid()
 {
     Assert.Throws <ValidationException>(() =>
                                         StateMachineBuilder.StateMachine()
                                         .StartAt("Initial")
                                         .State("Initial", StateMachineBuilder.ParallelState()
                                                .Branch(StateMachineBuilder.SubStateMachine()
                                                        .StartAt("InitialBranchState")
                                                        .State("InitialBranchState", StateMachineBuilder.SucceedState()))
                                                .Transition(StateMachineBuilder.End())
                                                .Catcher(StateMachineBuilder.Catcher()
                                                         .Transition(StateMachineBuilder.Next("NoSuchState"))))
                                         .Build());
 }
Esempio n. 5
0
 public void CatcherInTaskState_CatchAllHasOtherErrorCodes_IsNotValid()
 {
     Assert.Throws <ValidationException>(() =>
                                         StateMachineBuilder.StateMachine()
                                         .StartAt("Initial")
                                         .State("Initial", StateMachineBuilder.TaskState()
                                                .Transition(StateMachineBuilder.End())
                                                .Catcher(StateMachineBuilder.Catcher()
                                                         .Transition(StateMachineBuilder.Next("Terminal"))
                                                         .ErrorEquals("Foo", "Bar", ErrorCodes.ALL))
                                                .Resource("arn"))
                                         .State("Terminal", StateMachineBuilder.SucceedState())
                                         .Build());
 }
Esempio n. 6
0
        public void SingleTaskStateWithCatchers()
        {
            var stateMachine = StateMachineBuilder.StateMachine()
                               .StartAt("InitialState")
                               .State("InitialState", StateMachineBuilder.TaskState()
                                      .Transition(StateMachineBuilder.Next("NextState"))
                                      .Resource("resource-arn")
                                      .Catchers(StateMachineBuilder.Catcher()
                                                .ErrorEquals("Foo", "Bar")
                                                .Transition(StateMachineBuilder.Next("RecoveryState"))
                                                .ResultPath("$.result-path"),
                                                StateMachineBuilder.Catcher()
                                                .CatchAll()
                                                .Transition(StateMachineBuilder.Next("OtherRecoveryState"))))
                               .State("NextState", StateMachineBuilder.SucceedState())
                               .State("RecoveryState", StateMachineBuilder.SucceedState())
                               .State("OtherRecoveryState", StateMachineBuilder.SucceedState())
                               .Build();

            AssertStateMachine(stateMachine, "SimpleTaskStateWithCatchers.json");
        }