Example #1
0
        public void TestIsPresent()
        {
            var c = StateMachineBuilder.ChoiceState()
                    .Choice(StateMachineBuilder.Choice()
                            .Transition(StateMachineBuilder.Next("NextState"))
                            .Condition(StateMachineBuilder.IsPresent("$.isPresent", true)))
                    .Choice(StateMachineBuilder.Choice()
                            .Transition(StateMachineBuilder.Next("NextState"))
                            .Condition(StateMachineBuilder.IsPresent("$.isNotPresent", false))
                            )
                    .Build();

            var choices = c.Choices.ToArray();

            Assert.True(choices[0].Condition.Match(JObject.Parse("{\"isPresent\":null}")));
            Assert.True(choices[0].Condition.Match(JObject.Parse("{\"isPresent\":33}")));
            Assert.False(choices[0].Condition.Match(JObject.Parse("{}")));

            Assert.True(choices[1].Condition.Match(JObject.Parse("{}")));
            Assert.False(choices[1].Condition.Match(JObject.Parse("{\"isNotPresent\":33}")));
        }