Exemple #1
0
        public void Add_SourcePlaceNoTokensOnlyIncomingArcOnTarget_CallbackFalse()
        {
            // arrange
            StubPlace source = new StubPlace("testSource", new List<INode> { }, new List<INode> { });
            source.TokenCount = 0;
            StubTransition target = new StubTransition("testTarget", new List<INode> { }, new List<INode> { });
            Arc testArc = new Arc(source, target, "testArc");
            source.Arcs = new List<IArc> { testArc };
            target.Arcs = new List<IArc> { testArc };

            // act
            testArc.Add(testCallback);

            // assert
            Assert.AreEqual(false, callbackCalled, "Callback required when arc is only incoming arc on target" +
                                                   "and source is place without tokens.");
            Assert.AreEqual("testTarget", callbackId, "Target id should be used in callback.");
        }
Exemple #2
0
        public void Add_SourcePlaceNoTokensSecondIncomingArcOnTargetSourceNoTokens_NoCallback()
        {
            // arrange
            StubPlace source = new StubPlace("testSource", new List<INode> { }, new List<INode> { });
            source.TokenCount = 0;
            StubPlace secondPredecessor = new StubPlace("testSecondPredecessor", new List<INode> { }, new List<INode> { });
            secondPredecessor.TokenCount = 0;
            StubTransition target = new StubTransition("testTarget", new List<INode> { secondPredecessor }, new List<INode> { });
            Arc testArc = new Arc(source, target, "testArc");
            source.Arcs = new List<IArc> { testArc };
            target.Arcs = new List<IArc> { testArc };

            // act
            testArc.Add(testCallback);

            // assert
            Assert.IsNull(callbackCalled, "No callback should occur when target already has predecessor with no tokens.");
        }
Exemple #3
0
        public void Add_SourcePlaceNoTokensSecondIncomingArcOnTargetSourceTokens_CallbackFalse()
        {
            // arrange
            StubPlace source = new StubPlace("testSource", new List<INode> { }, new List<INode> { });
            source.TokenCount = 0;
            StubPlace secondPredecessor = new StubPlace("testSecondPredecessor", new List<INode> { }, new List<INode> { });
            secondPredecessor.TokenCount = new Random().Next(1, 999);
            StubTransition target = new StubTransition("testTarget", new List<INode> { secondPredecessor }, new List<INode> { });
            Arc testArc = new Arc(source, target, "testArc");
            source.Arcs = new List<IArc> { testArc };
            target.Arcs = new List<IArc> { testArc };

            // act
            testArc.Add(testCallback);

            // assert
            Assert.AreEqual(false, callbackCalled, "Callback required when all other predecessors of target have tokens.");
            Assert.AreEqual("testTarget", callbackId, "Target id should be used in callback.");
        }
Exemple #4
0
        public void Add_SourcePlaceTokensTargetTrans_NoCallback()
        {
            // arrange
            StubPlace source = new StubPlace("testSource", new List<INode> { }, new List<INode> { });
            source.TokenCount = new Random().Next(1, 999);
            StubTransition target = new StubTransition("testTarget", new List<INode> { }, new List<INode> { });
            Arc testArc = new Arc(source, target, "testArc");
            source.Arcs = new List<IArc> { testArc };
            target.Arcs = new List<IArc> { testArc };

            // act
            testArc.Add(testCallback);

            // assert
            Assert.IsNull(callbackCalled, "No callback should occur when source has tokens.");
        }
Exemple #5
0
        public void Remove_SourceTransTargetPlace_NoCallback()
        {
            // arrange
            StubTransition source = new StubTransition("testSource", new List<INode> { }, new List<INode> { });
            StubPlace target = new StubPlace("testTarget", new List<INode> { }, new List<INode> { });
            Arc testArc = new Arc(source, target, "testArc");
            source.Arcs = new List<IArc> { testArc };
            target.Arcs = new List<IArc> { testArc };

            // act
            testArc.Remove(testCallback);

            // assert
            Assert.IsNull(callbackCalled, "No callback should occur when target is Place.");
        }
Exemple #6
0
        public void Equals_CompareToString_ReturnsFalse()
        {
            // arrange
            StubPlace sourcePlace = new StubPlace("sourcePlace", new List<INode> { }, new List<INode> { });
            StubTransition targetTrans = new StubTransition("targetTrans", new List<INode> { }, new List<INode> { });
            Arc testArc = new Arc(sourcePlace, targetTrans, "testArc");

            // act
            bool result = testArc.Equals("testString");

            // assert
            Assert.IsFalse(result, "Comparison with other type should always return false.");
        }
Exemple #7
0
        public void Equals_CompareToSameArc_ReturnsTrue()
        {
            // arrange
            StubPlace sourcePlace = new StubPlace("sourcePlace", new List<INode> { }, new List<INode> { });
            StubTransition targetTrans = new StubTransition("targetTrans", new List<INode> { }, new List<INode> { });
            Arc testArc = new Arc(sourcePlace, targetTrans, "testArc");

            // act
            bool result = testArc.Equals(testArc);

            // assert
            Assert.IsTrue(result, "Comparison with same arc should return true.");
        }
Exemple #8
0
        public void Equals_CompareToDifferentArc_ReturnsFalse()
        {
            // arrange
            StubPlace sourcePlace = new StubPlace("sourcePlace", new List<INode> { }, new List<INode> { });
            StubTransition targetTrans = new StubTransition("targetTrans", new List<INode> { }, new List<INode> { });
            Arc testArc = new Arc(sourcePlace, targetTrans, "testArc");
            Arc differentArc = new Arc(sourcePlace, targetTrans, "differentArc");

            // act
            bool result = testArc.Equals(differentArc);

            // assert
            Assert.IsFalse(result, "Comparison with arc with different id should return false.");
        }
Exemple #9
0
        public void ArcConstructor_TargetNull_ThrowsArgumentNullException()
        {
            // arrange
            StubPlace sourcePlace = new StubPlace("sourcePlace", new List<INode> { }, new List<INode> { });

            // act
            Arc testArc = new Arc(sourcePlace, null, "testArc");
        }
Exemple #10
0
        public void ArcConstructor_SourceTransitionTargetTransition_ThrowsInvalidOperationException()
        {
            // arrange
            StubTransition sourceTrans = new StubTransition("sourceTrans", new List<INode> { }, new List<INode> { });
            StubTransition targetTrans = new StubTransition("targetTrans", new List<INode> { }, new List<INode> { });

            // act
            Arc testArc = new Arc(sourceTrans, targetTrans, "testArc");
        }
Exemple #11
0
        public void ArcConstructor_SourcePlaceTargetPlace_ThrowsInvalidOperationException()
        {
            // arrange
            StubPlace sourcePlace = new StubPlace("sourcePlace", new List<INode> { }, new List<INode> { });
            StubPlace targetPlace = new StubPlace("targetPlace", new List<INode> { }, new List<INode> { });

            // act
            Arc testArc = new Arc(sourcePlace, targetPlace, "testArc");
        }
Exemple #12
0
        public void ArcConstructor_IdNull_ThrowsArgumentNullException()
        {
            // arrange
            StubPlace sourcePlace = new StubPlace("sourcePlace", new List<INode> { }, new List<INode> { });
            StubTransition targetTrans = new StubTransition("targetTrans", new List<INode> { }, new List<INode> { });

            // act
            Arc testArc = new Arc(sourcePlace, targetTrans, null);
        }
Exemple #13
0
        public void ArcConstructor_AllLegalParameters_ConstructsValidArc()
        {
            // arrange
            StubPlace sourcePlace = new StubPlace("sourcePlace", new List<INode> { }, new List<INode> { });
            StubTransition targetTrans = new StubTransition("targetTrans", new List<INode> { }, new List<INode> { });

            // act
            Arc testArc = new Arc(sourcePlace, targetTrans, "testArc");

            // assert
            Assert.IsNotNull(testArc);
        }