예제 #1
0
        public void TransitionSystem2()
        {
            TransitionSystem system = CreateTransitionSystem2();

            Console.WriteLine(system);

            // Determine possible reactive transitions.
            ItemEventArgsNew systemEvent = new ItemEventArgsNew()
            {
                GUID       = guids[0],
                SystemName = systemNames[0],
                Position   = positions[0],
                Rotation   = rotations[0],
                ModelGroup = modelGroups[0],
                Model      = models[0],
            };

            Console.WriteLine("Using system event: " + systemEvent);
            HashSet <ReactiveTransition> reactives = system.PossibleReactiveTransitions(systemEvent);

            Console.WriteLine("Possible reactive transitions: " + string.Join(", ", reactives.Select(x => x.ToString()).ToArray()));
            Assert.AreEqual(1, reactives.Count);
            Assert.AreEqual(system.Transitions.ElementAt(0), reactives.First());

            // Execute and check reactive transition.
            system.ExecuteReactiveTransition(systemEvent, reactives.First());
            Console.WriteLine(system);
            Assert.AreEqual(system.States.ElementAt(1), system.CurrentState);

            // Determine possible proactive transitions.
            HashSet <ProactiveTransition> proactives = system.PossibleProactiveTransitions();

            Console.WriteLine("Possible proactive transitions: " + string.Join(", ", proactives.Select(x => x.ToString()).ToArray()));
            Assert.AreEqual(1, proactives.Count);
            Assert.AreEqual(system.Transitions.ElementAt(1), proactives.First());

            // Execute and check proactive transition.
            IAction generatedAction = system.ExecuteProactiveTransition(proactives.First());

            Console.WriteLine("Generated action: " + generatedAction);
            Assert.AreEqual(typeof(NewItem), generatedAction.GetType());
            Assert.AreEqual(1, (generatedAction as NewItem).Id);
            Console.WriteLine(system);
            Assert.AreEqual(system.States.ElementAt(0), system.CurrentState);
        }
예제 #2
0
        public void TransitionSystem1()
        {
            TransitionSystem system = CreateTransitionSystem1();

            Console.WriteLine(system);

            // Determine possible reactive transitions.
            NewItem modelInput = new NewItem()
            {
                Id = 1,
            };

            Console.WriteLine("Using model input: " + modelInput);
            HashSet <ReactiveTransition> reactives = system.PossibleReactiveTransitions(modelInput);

            Console.WriteLine("Possible reactive transitions: " + string.Join(", ", reactives.Select(x => x.ToString()).ToArray()));
            Assert.AreEqual(1, reactives.Count);
            Assert.AreEqual(system.Transitions.ElementAt(0), reactives.First());

            // Execute and check reactive transition.
            system.ExecuteReactiveTransition(modelInput, reactives.First());
            Console.WriteLine(system);
            Assert.AreEqual(system.States.ElementAt(1), system.CurrentState);

            // Determine possible proactive transitions.
            HashSet <ProactiveTransition> proactives = system.PossibleProactiveTransitions();

            Console.WriteLine("Possible proactive transitions: " + string.Join(", ", proactives.Select(x => x.ToString()).ToArray()));
            Assert.AreEqual(1, proactives.Count);
            Assert.AreEqual(system.Transitions.ElementAt(1), proactives.First());

            // Execute and check proactive transition.
            IAction generatedAction = system.ExecuteProactiveTransition(proactives.First());

            Console.WriteLine("Generated action: " + generatedAction);
            Assert.AreEqual(typeof(ItemEventArgsNew), generatedAction.GetType());
            Assert.AreEqual(guids[0], (generatedAction as ItemEventArgsNew).GUID);
            Console.WriteLine(system);
            Assert.AreEqual(system.States.ElementAt(0), system.CurrentState);
        }