public void Test_GetWorkflowHistory_TwoLevel() { // Testing an ideal 6 item Workflow history "tree" var pRoot = new Procedure(); // associative Procedure to first level var ps1 = new ConcreteProcedureStep(pRoot); // First level var p1 = new Procedure(); // associative Procedure to left branch of second level var ps11 = new ConcreteProcedureStep(p1); // Second level, left branch var ps12 = new ConcreteProcedureStep(p1); // Second level, left branch ps11.AddRelatedStep(ps12); // Relate children ps1.LinkTo(ps11); // Link adjacent levels var ps2 = new ConcreteProcedureStep(pRoot); // First level var p2 = new Procedure(); // associative Procedure to right branch of second level var ps21 = new ConcreteProcedureStep(p2); // Second level, right branch var ps22 = new ConcreteProcedureStep(p2); // Second level, right branch ps21.AddRelatedStep(ps22); // Relate children ps2.LinkTo(ps21); // Link adjacent levels Assert.AreEqual(6, pRoot.GetWorkflowHistory().Count); // Assert all items in "tree" are present in Workflow history }
public void Test_GetWorkflowHistory_UnrelatedSteps() { // This "tree" doesn't have the right children of each pair in the third level // Due to the abscence of relating these steps var pRoot = new Procedure(); // associative Procedure to first level var ps1 = new ConcreteProcedureStep(pRoot); var p1 = new Procedure(); // associative Procedure to left branch of second level var ps11 = new ConcreteProcedureStep(p1); var p11 = new Procedure(); // associative Procedure to leftmost branch of third level var ps111 = new ConcreteProcedureStep(p11); var ps112 = new ConcreteProcedureStep(p11); // is not related to ps111 ps11.LinkTo(ps111); // link adjacent levels var ps12 = new ConcreteProcedureStep(p1); var p12 = new Procedure(); // associative Procedure to second leftmost branch of third level var ps121 = new ConcreteProcedureStep(p12); var ps122 = new ConcreteProcedureStep(p12); // is not related to ps121 ps12.LinkTo(ps121); // link adjacent levels ps11.AddRelatedStep(ps12); // relate steps of p1 ps1.LinkTo(ps11); // link adjacent levels var ps2 = new ConcreteProcedureStep(pRoot); var p2 = new Procedure(); // associative Procedure to right branch of second level var ps21 = new ConcreteProcedureStep(p2); var p21 = new Procedure(); // associative Procedure to second rightmost branch of third level var ps211 = new ConcreteProcedureStep(p21); var ps212 = new ConcreteProcedureStep(p21); // is not related to ps211 ps21.LinkTo(ps211); // link adjacent levels var ps22 = new ConcreteProcedureStep(p2); var p22 = new Procedure(); // associative Procedure to rightmost branch of third level var ps221 = new ConcreteProcedureStep(p22); var ps222 = new ConcreteProcedureStep(p22); // is not related to ps221 ps22.LinkTo(ps221); // link adjacent levels ps21.AddRelatedStep(ps22); // relate steps of p2 ps2.LinkTo(ps21); // link adjacent levels Assert.AreEqual(10, pRoot.GetWorkflowHistory().Count); // Assert all items in "tree" are present in Workflow history... except these ones: Assert.IsFalse(pRoot.GetWorkflowHistory().Contains(ps112)); Assert.IsFalse(pRoot.GetWorkflowHistory().Contains(ps122)); Assert.IsFalse(pRoot.GetWorkflowHistory().Contains(ps212)); Assert.IsFalse(pRoot.GetWorkflowHistory().Contains(ps222)); }
public void Test_GetWorkflowHistory_ThreeLevel() { var pRoot = new Procedure(); // associative Procedure to first level var ps1 = new ConcreteProcedureStep(pRoot); var p1 = new Procedure(); // associative Procedure to left branch of second level var ps11 = new ConcreteProcedureStep(p1); var p11 = new Procedure(); // associative Procedure to leftmost branch of third level var ps111 = new ConcreteProcedureStep(p11); var ps112 = new ConcreteProcedureStep(p11); ps111.AddRelatedStep(ps112); // relate steps of p11 ps11.LinkTo(ps111); // link adjacent levels var ps12 = new ConcreteProcedureStep(p1); var p12 = new Procedure(); // associative Procedure to second leftmost branch of third level var ps121 = new ConcreteProcedureStep(p12); var ps122 = new ConcreteProcedureStep(p12); ps121.AddRelatedStep(ps122); // relate steps of p12 ps12.LinkTo(ps121); // link adjacent levels ps11.AddRelatedStep(ps12); // relate steps of p1 ps1.LinkTo(ps11); // link adjacent levels var ps2 = new ConcreteProcedureStep(pRoot); var p2 = new Procedure(); // associative Procedure to right branch of second level var ps21 = new ConcreteProcedureStep(p2); var p21 = new Procedure(); // associative Procedure to second rightmost branch of third level var ps211 = new ConcreteProcedureStep(p21); var ps212 = new ConcreteProcedureStep(p21); ps211.AddRelatedStep(ps212); // relate steps of p21 ps21.LinkTo(ps211); // link adjacent levels var ps22 = new ConcreteProcedureStep(p2); var p22 = new Procedure(); // associative Procedure to rightmost branch of third level var ps221 = new ConcreteProcedureStep(p22); var ps222 = new ConcreteProcedureStep(p22); ps221.AddRelatedStep(ps222); // relate steps of p22 ps22.LinkTo(ps221); // link adjacent levels ps21.AddRelatedStep(ps22); // relate steps of p2 ps2.LinkTo(ps21); // link adjacent levels Assert.AreEqual(14, pRoot.GetWorkflowHistory().Count); // Assert all items in "tree" are present in Workflow history }
public void Test_LinkTo_LinkingNotSupported() { Procedure p1 = new Procedure(); Procedure p2 = new Procedure(); // create proc steps that don't support linking ConcreteProcedureStep ps1 = new ConcreteProcedureStep(p1, false); ConcreteProcedureStep ps2 = new ConcreteProcedureStep(p2, false); // should throw, because linking is not supported ps1.LinkTo(ps2); }
public void Test_LinkTo() { Procedure p1 = new Procedure(); Procedure p2 = new Procedure(); // create proc steps that support linking ConcreteProcedureStep ps1 = new ConcreteProcedureStep(p1, true); ConcreteProcedureStep ps2 = new ConcreteProcedureStep(p2, true); Assert.AreEqual(ActivityStatus.SC, ps1.State); // pre-conditions: // both link step properties are null (not set), and // linked procedure lists are emtpy Assert.IsNull(ps1.LinkStep); Assert.IsFalse(ps1.IsLinked); Assert.IsEmpty(ps1.GetLinkedProcedures()); Assert.IsNull(ps2.LinkStep); Assert.IsFalse(ps2.IsLinked); Assert.IsEmpty(ps2.GetLinkedProcedures()); // link step 1 to step 2 ps1.LinkTo(ps2); // which should discontinue step 1 Assert.AreEqual(ActivityStatus.DC, ps1.State); // expect the ps1.LinkStep is set to point to ps2 Assert.AreEqual(ps2, ps1.LinkStep); Assert.IsTrue(ps1.IsLinked); // ps1 is linked // expect ps1 does not have any linked procedures, // and AllProcedures returns only ps1 Assert.IsEmpty(ps1.GetLinkedProcedures()); Assert.AreEqual(1, ps1.AllProcedures.Count); Assert.Contains(p1, ps1.AllProcedures); // expect ps2 is still not linked Assert.IsNull(ps2.LinkStep); Assert.IsFalse(ps2.IsLinked); // ps2 is not linked // expect ps2 has exactly 1 linked procedure, which is p1 Assert.AreEqual(1, ps2.GetLinkedProcedures().Count); Assert.Contains(p1, ps2.GetLinkedProcedures()); // expect AllProcedures contains both p1 and p2 Assert.AreEqual(2, ps2.AllProcedures.Count); Assert.Contains(p1, ps2.AllProcedures); Assert.Contains(p2, ps2.AllProcedures); }
public void Test_LinkTo_StateNotScheduled() { Procedure p1 = new Procedure(); Procedure p2 = new Procedure(); // create proc steps that support linking ConcreteProcedureStep ps1 = new ConcreteProcedureStep(p1, true); ConcreteProcedureStep ps2 = new ConcreteProcedureStep(p2, true); ps1.Discontinue(); Assert.AreEqual(ActivityStatus.DC, ps1.State); // should throw, because only a scheduled step can be linked to another ps1.LinkTo(ps2); }