Пример #1
0
        public void RemoveNodeAndConnectionsTest()
        {
            Model.PetriNet.PetriNet testNet = new Model.PetriNet.PetriNet("TestNet");
            Place      testPlace1           = testNet.AddPlace("TestPlace1");
            Place      testPlace2           = testNet.AddPlace("TestPlace2");
            Place      testPlace3           = testNet.AddPlace("TestPlace3");
            Transition testTransition1      = testNet.AddTransition("TestTransition1", incomingPlace: testPlace1, outgoingPlace: testPlace2);
            Transition testTransition2      = testNet.AddTransition("TestTransition2", incomingPlace: testPlace2, outgoingPlace: testPlace3);

            testNet.RemoveNodeAndConnections(testPlace2);

            Assert.AreEqual(0, testTransition1.OutgoingPlaces.Count);
            Assert.AreEqual(0, testTransition2.IncomingPlaces.Count);
            Assert.IsFalse(testNet.Places.Contains(testPlace2));

            testNet.RemoveNodeAndConnections(testTransition2);

            Assert.AreEqual(0, testPlace3.IncomingTransitions.Count);
        }
        public void RemoveNodeAndConnectionsTest()
        {
            Model.PetriNet.PetriNet testNet = new Model.PetriNet.PetriNet("TestNet");
            Place testPlace1 = testNet.AddPlace("TestPlace1");
            Place testPlace2 = testNet.AddPlace("TestPlace2");
            Place testPlace3 = testNet.AddPlace("TestPlace3");
            Transition testTransition1 = testNet.AddTransition("TestTransition1", incomingPlace: testPlace1, outgoingPlace: testPlace2);
            Transition testTransition2 = testNet.AddTransition("TestTransition2", incomingPlace: testPlace2, outgoingPlace: testPlace3);

            testNet.RemoveNodeAndConnections(testPlace2);

            Assert.AreEqual(0, testTransition1.OutgoingPlaces.Count);
            Assert.AreEqual(0, testTransition2.IncomingPlaces.Count);
            Assert.IsFalse(testNet.Places.Contains(testPlace2));

            testNet.RemoveNodeAndConnections(testTransition2);

            Assert.AreEqual(0, testPlace3.IncomingTransitions.Count);
        }