Esempio n. 1
0
        public void TestIsBoolean()
        {
            var c = StateMachineBuilder.ChoiceState()
                    .Choice(StateMachineBuilder.Choice()
                            .Transition(StateMachineBuilder.Next("NextState"))
                            .Condition(StateMachineBuilder.IsBoolean("$.isBoolean", true)))
                    .Choice(StateMachineBuilder.Choice()
                            .Transition(StateMachineBuilder.Next("NextState"))
                            .Condition(StateMachineBuilder.IsBoolean("$.isBoolean", false))
                            )
                    .Build();

            var choices = c.Choices.ToArray();

            Assert.False(choices[0].Condition.Match(JObject.FromObject(new { isBoolean = "str" })));
            Assert.False(choices[0].Condition.Match(JObject.FromObject(new { isBoolean = DateTime.Now })));
            Assert.False(choices[0].Condition.Match(JObject.FromObject(new { isBoolean = 33 })));
            Assert.False(choices[0].Condition.Match(JObject.FromObject(new { isBoolean = 33.23 })));
            Assert.True(choices[0].Condition.Match(JObject.FromObject(new { isBoolean = true })));

            Assert.True(choices[1].Condition.Match(JObject.FromObject(new { isBoolean = "str" })));
            Assert.True(choices[1].Condition.Match(JObject.FromObject(new { isBoolean = DateTime.Now })));
            Assert.True(choices[1].Condition.Match(JObject.FromObject(new { isBoolean = 33 })));
            Assert.True(choices[1].Condition.Match(JObject.FromObject(new { isBoolean = 33.23 })));
            Assert.False(choices[1].Condition.Match(JObject.FromObject(new { isBoolean = true })));
        }