Esempio n. 1
0
        public void TestMatchOperatorWithJObject()
        {
            var c = StateMachineBuilder.ChoiceState()
                    .Choice(StateMachineBuilder.Choice()
                            .Transition(StateMachineBuilder.Next("NextState"))
                            .Condition(StateMachineBuilder.Match("$.varstr", "val*")))
                    .Choice(StateMachineBuilder.Choice()
                            .Transition(StateMachineBuilder.Next("NextState"))
                            .Condition(StateMachineBuilder.Match("$.varstr", "val*ue")))
                    .Choice(StateMachineBuilder.Choice()
                            .Transition(StateMachineBuilder.Next("NextState"))
                            .Condition(StateMachineBuilder.Match("$.varstr", "val\\*ue")))
                    .Build();

            var choices = c.Choices.ToArray();

            Assert.True(choices[0].Condition.Match(JObject.FromObject(new { varstr = "value" })));
            Assert.False(choices[0].Condition.Match(JObject.FromObject(new { varstr = "test" })));

            Assert.True(choices[1].Condition.Match(JObject.FromObject(new { varstr = "value" })));
            Assert.True(choices[1].Condition.Match(JObject.FromObject(new { varstr = "valDFDFDFue" })));

            Assert.True(choices[2].Condition.Match(JObject.FromObject(new { varstr = "val*ue" })));
            Assert.False(choices[2].Condition.Match(JObject.FromObject(new { varstr = "value" })));
        }