Пример #1
0
        public void InverseTransitionTokens_NoSucessorsNoPredecessors_NoCallback()
        {
            // arrange
            Transition testTrans = new Transition(0, 0, "testTransition");
            testTrans.Predecessors.Clear();
            testTrans.Successors.Clear();

            // act
            testTrans.InverseTransitionTokens((s, b) => { }, testCallback);

            // assert
            Assert.AreEqual(0, callbackIds.Count, "No callback should occur when there are no successors or predecessors.");
        }
Пример #2
0
        public void InverseTransitionTokens_NoSuccessorsTwoPredecessors_CallbackTwice()
        {
            // arrange
            Transition testTrans = new Transition(0, 0, "testTransition");
            testTrans.Successors.Clear();
            IList<String> predecessorIds = new List<String> { "predecessor_1", "predecessor_2" };
            int tokenCount = new Random().Next(0, 999);
            StubPlace predecessor_1 = new StubPlace(predecessorIds[0], new List<INode> { testTrans }, new List<INode> { });
            predecessor_1.TokenCount = tokenCount;
            StubPlace predecessor_2 = new StubPlace(predecessorIds[1], new List<INode> { testTrans }, new List<INode> { });
            predecessor_2.TokenCount = tokenCount;
            testTrans.Predecessors.Clear();
            testTrans.Predecessors.Add(predecessor_1);
            testTrans.Predecessors.Add(predecessor_2);

            // act
            testTrans.InverseTransitionTokens((s, b) => { }, testCallback);

            // assert
            Assert.IsTrue(Compare.UnorderedEqual(predecessorIds, callbackIds), "Callback called with incorrect ids.");
            Assert.AreEqual(tokenCount + 1, predecessor_2.TokenCount, "TokenCount not increased correctly.");
        }
Пример #3
0
        public void TransitionTokens_OneSuccessorZeroTokens_ThrowsInvalidOperationException()
        {
            // arrange
            Transition testTrans = new Transition(0, 0, "testTransition");
            testTrans.Predecessors.Clear();
            IList<String> successorIds = new List<String> { "successor_1" };
            StubPlace successor_1 = new StubPlace(successorIds[0], new List<INode> { }, new List<INode> { testTrans });
            successor_1.TokenCount = 0;
            testTrans.Successors.Clear();
            testTrans.Successors.Add(successor_1);

            // act
            testTrans.InverseTransitionTokens((s, b) => { }, testCallback);
        }