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."); }
public void Remove_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.Remove(testCallback); // assert Assert.IsNull(callbackCalled, "No callback should occur when source has tokens."); }
public void Remove_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.Remove(testCallback); // assert Assert.IsNull(callbackCalled, "No callback should occur when target already has predecessor with no tokens."); }
public void Remove_SourcePlaceNoTokensSecondIncomingArcOnTargetSourceTokens_CallbackTrue() { // 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.Remove(testCallback); // assert Assert.AreEqual(true, callbackCalled, "Callback required when all other predecessors of target have tokens."); Assert.AreEqual("testTarget", callbackId, "Target id should be used in callback."); }
public void Remove_SourcePlaceNoTokensOnlyIncomingArcOnTarget_CallbackTrue() { // 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.Remove(testCallback); // assert Assert.AreEqual(true, 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."); }