Beispiel #1
0
        private void AssertSimilar(FSM.FiniteStateMachine fsm, PN.PetriNet pn, ITransformationTrace trace)
        {
            Assert.AreEqual(fsm.ID, pn.ID, "The ID of the petri net is not set correctly");
            Assert.AreEqual(fsm.States.Count, pn.Places.Count, "The number of places is incorrect");
            Assert.AreEqual(fsm.Transitions.Count + fsm.States.Where(s => s.IsEndState).Count(), pn.Transitions.Count,
                            "The number of transitions is incorrect");

            foreach (var state in fsm.States)
            {
                var place = trace.Resolve <FSM.State, PN.Place>(state);

                Assert.IsNotNull(place, "A state has not been transformed");
                Assert.AreEqual(state.Name, place.ID, "The name of a place has not been set correctly");
                Assert.IsTrue(pn.Places.Contains(place), "A corresponding place has not been added to the states of the Petri net");

                if (state.IsStartState)
                {
                    Assert.AreEqual(1, place.TokenCount, "The number of tokens has not been set");
                }
                else
                {
                    Assert.AreEqual(0, place.TokenCount, "The number of tokens has not been set");
                }

                foreach (var t in state.Transitions)
                {
                    var t2 = trace.Resolve <FSM.Transition, PN.Transition>(t);

                    Assert.IsNotNull(t2, "A transition has not been transformed");
                    Assert.IsTrue(pn.Transitions.Contains(t2), "A transition has not been added to the transitions of the Petri net");
                }
            }
        }
Beispiel #2
0
        public void Transformations_AbstractTrace_Resolve2()
        {
            Assert.AreEqual("b", trace.ResolveIn <string, string>(ruleT1, "a"));
            Assert.AreEqual(null, trace.ResolveIn <string, string>(ruleT1, "b"));
            Assert.AreEqual(null, trace.ResolveIn <string, string>(ruleT1, "c"));

            Assert.AreEqual("b", trace.Resolve <string, string>("a"));
            Assert.AreEqual(null, trace.Resolve <string, string>("b"));
            Assert.AreEqual(null, trace.Resolve <string, string>("c"));
        }
Beispiel #3
0
        private void AssertSimilar(FSM.FiniteStateMachine fsm, PN.PetriNet pn, ITransformationTrace trace)
        {
            Assert.AreEqual(fsm.ID, pn.ID, "The ID of the petri net is not set correctly");
            Assert.AreEqual(fsm.States.Count, pn.Places.Count, "The number of places is incorrect");
            Assert.AreEqual(fsm.Transitions.Count + fsm.States.Where(s => s.IsEndState).Count(), pn.Transitions.Count,
                "The number of transitions is incorrect");

            foreach (var state in fsm.States)
            {
                var place = trace.Resolve<FSM.State, PN.Place>(state);

                Assert.IsNotNull(place, "A state has not been transformed");
                Assert.AreEqual(state.Name, place.ID, "The name of a place has not been set correctly");
                Assert.IsTrue(pn.Places.Contains(place), "A corresponding place has not been added to the states of the Petri net");

                if (state.IsStartState)
                {
                    Assert.AreEqual(1, place.TokenCount, "The number of tokens has not been set");
                }
                else
                {
                    Assert.AreEqual(0, place.TokenCount, "The number of tokens has not been set");
                }

                foreach (var t in state.Transitions)
                {
                    var t2 = trace.Resolve<FSM.Transition, PN.Transition>(t);

                    Assert.IsNotNull(t2, "A transition has not been transformed");
                    Assert.IsTrue(pn.Transitions.Contains(t2), "A transition has not been added to the transitions of the Petri net");
                }
            }
        }