コード例 #1
0
        public void TestIsNull()
        {
            var c = StateMachineBuilder.ChoiceState()
                    .Choice(StateMachineBuilder.Choice()
                            .Transition(StateMachineBuilder.Next("NextState"))
                            .Condition(StateMachineBuilder.IsNull("$.isNull", true)))
                    .Choice(StateMachineBuilder.Choice()
                            .Transition(StateMachineBuilder.Next("NextState"))
                            .Condition(StateMachineBuilder.IsNull("$.isNotNull", false))
                            )
                    .Build();

            var choices = c.Choices.ToArray();

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

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