Beispiel #1
0
        private Pn.Place AssertOriginalPetriNet(Pn.PetriNet pn, ISynchronizationContext context, Fsm.State s1)
        {
            Assert.AreSame(pn, this.pn);
            Assert.AreEqual(3, pn.Places.Count);
            Assert.AreEqual(2, pn.Transitions.Count);

            var place = pn.Places.FirstOrDefault(p => p.Id == "s1");

            Assert.IsNotNull(place);

            Assert.AreEqual(2, place.Outgoing.Count);
            Assert.AreEqual(0, place.Incoming.Count);

            if (s1 != null)
            {
                Assert.AreSame(place, context.Trace.ResolveIn(fsm2pn.SynchronizationRule<FSM2PN.StateToPlace>().LeftToRight, s1));
            }
            return place;
        }
Beispiel #2
0
        private Pn.Place AssertFsmLikePetriNet(Pn.PetriNet pn, ISynchronizationContext context, Fsm.State s1)
        {
            Assert.AreSame(pn, this.pn);
            Assert.AreEqual(3, pn.Places.Count);
            Assert.AreEqual(5, pn.Transitions.Count);

            var s1Place = context.Trace.ResolveIn(fsm2pn.SynchronizationRule<FSM2PN.StateToPlace>().LeftToRight, s1);

            Assert.IsNotNull(s1Place);

            Assert.AreEqual(2, s1Place.Outgoing.Count);
            Assert.AreEqual(2, s1Place.Incoming.Count);

            Assert.AreEqual("s1", s1Place.Id);

            return s1Place;
        }
Beispiel #3
0
        private void AssertOneWayUpdatesPetriNetToFsm(Pn.Place p1, Fsm.State p1State)
        {
            if (p1 == null) return;

            p1.Id = "foo2";

            Assert.AreEqual("foo2", p1State.Name);
            Assert.IsFalse(p1State.IsEndState);

            var t = new Pn.Transition();
            t.From.Add(p1);
            pn.Transitions.Add(t);

            Assert.IsTrue(p1State.IsEndState);
        }
Beispiel #4
0
 private Pn.Place AssertEmptyPetriNet(Pn.PetriNet pn)
 {
     Assert.AreSame(pn, this.pn);
     Assert.AreEqual(0, pn.Places.Count);
     Assert.AreEqual(0, pn.Transitions.Count);
     return null;
 }
Beispiel #5
0
        private void AssertOneWayUpdatesFsmToPetriNet(Fsm.State s1, Pn.Place s1Place)
        {
            if (s1 == null) return;

            s1.Name = "foo1";

            Assert.AreEqual("foo1", s1Place.Id);

            var oldTransitions = pn.Transitions.Count;

            s1.IsEndState = true;

            Assert.AreEqual(oldTransitions + 1, pn.Transitions.Count);
            Assert.IsTrue(s1Place.Outgoing.Any(t => t.To.Count == 0));

            s1.IsEndState = false;

            Assert.AreEqual(oldTransitions, pn.Transitions.Count);
            Assert.IsFalse(s1Place.Outgoing.Any(t => t.To.Count == 0));
        }