Пример #1
0
        public void TestIsString()
        {
            var c = StateMachineBuilder.ChoiceState()
                    .Choice(StateMachineBuilder.Choice()
                            .Transition(StateMachineBuilder.Next("NextState"))
                            .Condition(StateMachineBuilder.IsString("$.isString", true)))
                    .Choice(StateMachineBuilder.Choice()
                            .Transition(StateMachineBuilder.Next("NextState"))
                            .Condition(StateMachineBuilder.IsString("$.isString", false))
                            )
                    .Build();

            var choices = c.Choices.ToArray();

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

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