コード例 #1
0
        public void GetGeneralizationTest()
        {
            var dcrGraph = new DcrGraph();

            var activityA = new Activity("A", "somename1") { Included = true, Pending = true };
            var activityB = new Activity("B", "somename2") { Included = false };
            var activityC = new Activity("C", "somename3") { Included = false };

            dcrGraph.AddActivities(activityA, activityB, activityC);

            dcrGraph.AddIncludeExclude(true, activityA.Id, activityB.Id);
            dcrGraph.AddIncludeExclude(true, activityB.Id, activityC.Id);
            dcrGraph.AddIncludeExclude(false, activityA.Id, activityA.Id);
            dcrGraph.AddIncludeExclude(false, activityB.Id, activityB.Id);

            var log = new Log();
            log.AddTrace(new LogTrace('A', 'B'));
            log.AddTrace(new LogTrace('A', 'B', 'C'));
            log.AddTrace(new LogTrace('A', 'B', 'C')); //duplicate trace should not matter
            log.AddTrace(new LogTrace('A', 'B', 'C', 'A')); //illegal execution should count down
            log.AddTrace(new LogTrace('A', 'B', 'C', 'A', 'A')); //this one should not matter, as we've already seen A been illegally executed from this state.

            var log2 = new Log();

            log2.AddTrace(new LogTrace('A', 'B'));

            var qd1 = QualityDimensionRetriever.Retrieve(dcrGraph, log);

            var qd2 = QualityDimensionRetriever.Retrieve(dcrGraph, log2);

            Assert.IsTrue(qd1.Generality > qd2.Generality);
        }
コード例 #2
0
        public void RedundantRemoverWithNested()
        {
            var dcrGraph = new DcrGraph();

            var activityA = new Activity("A", "somename1") { Included = true };
            var activityB = new Activity("B", "somename2") { Included = true };
            var activityC = new Activity("C", "somename3") { Included = true };
            var activityD = new Activity("D", "somename4") { Included = false };
            var activityE = new Activity("E", "somename5") { Included = true };
            var activityF = new Activity("F", "somename6") { Included = true };

            dcrGraph.AddActivities(activityA, activityB, activityC, activityD, activityE, activityF);

            dcrGraph.AddIncludeExclude(true, activityC.Id,activityD.Id);
            dcrGraph.AddIncludeExclude(true, activityC.Id, activityE.Id); //Redundant include
            dcrGraph.AddCondition(activityE.Id,activityF.Id); //outgoing relation
            //ingoing relation
            dcrGraph.AddCondition(activityA.Id,activityC.Id);
            dcrGraph.AddCondition(activityA.Id, activityD.Id);
            dcrGraph.AddCondition(activityA.Id, activityE.Id);

            dcrGraph.MakeNestedGraph(new HashSet<Activity>() {activityC, activityD, activityE});

            var newGraph = new RedundancyRemover().RemoveRedundancy(dcrGraph);

            //we check that the Nested graph has had the redundant relation removed.
            Assert.IsFalse(newGraph.InRelation(activityE,newGraph.IncludeExcludes));
        }
コード例 #3
0
        public void CopyNestedTest()
        {
            var dcrGraph = new DcrGraph();

            var activityA = new Activity("A", "somename1") { Included = true };
            var activityB = new Activity("B", "somename2") { Included = true };
            var activityC = new Activity("C", "somename3") { Included = true };
            var activityD = new Activity("D", "somename4") { Included = false };
            var activityE = new Activity("E", "somename5") { Included = true };
            var activityF = new Activity("F", "somename6") { Included = true };

            dcrGraph.AddActivity(activityC.Id, activityC.Name);
            dcrGraph.AddActivity(activityD.Id, activityD.Name);
            dcrGraph.AddActivity(activityE.Id, activityE.Name);
            dcrGraph.AddIncludeExclude(true, activityC.Id, activityD.Id);
            dcrGraph.AddActivity(activityA.Id, activityA.Name);
            dcrGraph.AddActivity(activityB.Id, activityB.Name);
            dcrGraph.AddActivity(activityF.Id, activityF.Name);
            dcrGraph.AddCondition(activityE.Id, activityF.Id); //outgoing relation
            //ingoing relations
            dcrGraph.AddCondition(activityA.Id, activityC.Id);
            dcrGraph.AddCondition(activityA.Id, activityD.Id);
            dcrGraph.AddCondition(activityA.Id, activityE.Id);

            dcrGraph.MakeNestedGraph(new HashSet<Activity>() { activityC, activityD, activityE });

            var copy = dcrGraph.Copy();

            Assert.AreEqual(dcrGraph.ToString(), copy.ToString());
        }
コード例 #4
0
        public void FitnessOnNestedGraph()
        {
            var dcrGraph = new DcrGraph();

            var activityA = new Activity("A", "somename1") { Included = true };
            var activityB = new Activity("B", "somename2") { Included = true };
            var activityC = new Activity("C", "somename3") { Included = true };
            var activityD = new Activity("D", "somename4") { Included = false };
            var activityE = new Activity("E", "somename5") { Included = true };
            var activityF = new Activity("F", "somename6") { Included = true };

            dcrGraph.AddActivities(activityA,activityB,activityC,activityD,activityE,activityF);
            dcrGraph.AddIncludeExclude(true, activityC.Id, activityD.Id);
            dcrGraph.AddCondition(activityE.Id, activityF.Id); //outgoing relation
            //ingoing relations
            dcrGraph.AddCondition(activityA.Id, activityC.Id);
            dcrGraph.AddCondition(activityA.Id, activityD.Id);
            dcrGraph.AddCondition(activityA.Id, activityE.Id);

            dcrGraph.MakeNestedGraph(new HashSet<Activity>() { activityC, activityD, activityE });

            var log = new Log();
            log.AddTrace(new LogTrace('A', 'C','D'));
            log.AddTrace(new LogTrace('A', 'B', 'C'));
            log.AddTrace(new LogTrace('A', 'E', 'F'));
            log.AddTrace(new LogTrace('C', 'E','D')); //illegal trace should count down

            //expecting fitness = 75%
            var qd = UlrikHovsgaardAlgorithm.QualityMeasures.QualityDimensionRetriever.Retrieve(dcrGraph, log);

            Assert.AreEqual(75d, qd.Fitness);
        }
コード例 #5
0
        public void CopyTest()
        {
            DcrGraph dcrGraph = new DcrGraph();

            var activityA = new Activity("A", "somename1") { Included = true, Pending = true };
            var activityB = new Activity("B", "somename2") { Included = true };
            var activityC = new Activity("C", "somename3") { Included = false };

            dcrGraph.AddActivities(activityA, activityB, activityC);

            dcrGraph.AddIncludeExclude(true, activityA.Id, activityB.Id);
            dcrGraph.AddIncludeExclude(true, activityB.Id, activityC.Id);

            var copy = dcrGraph.Copy();

            Assert.AreEqual(dcrGraph.ToString(), copy.ToString());
        }
コード例 #6
0
        public void RedundancyTestCase7()
        {
            var dcrGraph = new DcrGraph();

            var activityA = new Activity("A", "somename1") { Included = false, Pending = true };
            var activityB = new Activity("B", "somename2") { Included = true };
            var activityC = new Activity("C", "somename3") { Included = true };

            dcrGraph.Activities.Add(activityA);
            dcrGraph.Activities.Add(activityB);
            dcrGraph.Activities.Add(activityC);

            dcrGraph.AddResponse(activityB.Id, activityA.Id);
            dcrGraph.AddIncludeExclude(true, activityC.Id, activityA.Id);
            dcrGraph.AddIncludeExclude(true, activityB.Id, activityA.Id);
            dcrGraph.AddIncludeExclude(false, activityA.Id, activityB.Id);

            var newGraph = new RedundancyRemover().RemoveRedundancy(dcrGraph);

            //Now either the redundant response relation or A's initial pending state should be removed:");
            Assert.IsFalse(newGraph.InRelation(activityA, newGraph.Responses) && newGraph.GetActivity(activityA.Id).Pending);
        }
コード例 #7
0
        public void RetrieveImageWithIncludeRelationTest()
        {
            var dcrGraph = new DcrGraph();

            var activityA = new Activity("A", "somename1") { Included = true };
            var activityB = new Activity("B", "somename2") { Included = false };

            dcrGraph.AddActivities(activityA, activityB);

            dcrGraph.AddIncludeExclude(true, activityA.Id, activityB.Id);

            var img = GraphImageRetriever.Retrieve(dcrGraph).Result;

            Assert.IsNotNull(img);
        }
コード例 #8
0
        public void MakeNestedGraphTest()
        {
            var dcrGraph = new DcrGraph();

            var activityA = new Activity("A", "somename1") { Included = false };
            var activityB = new Activity("B", "somename2") { Included = true };
            var activityC = new Activity("C", "somename3") { Included = true };
            var activityD = new Activity("D", "somename4") { Included = false };
            var activityE = new Activity("E", "somename5") { Included = true };
            var activityF = new Activity("F", "somename6") { Included = true };

            dcrGraph.AddActivity(activityC.Id, activityC.Name);
            dcrGraph.AddActivity(activityD.Id, activityD.Name);
            dcrGraph.AddActivity(activityE.Id, activityE.Name);
            dcrGraph.AddIncludeExclude(true, activityC.Id, activityD.Id);
            dcrGraph.AddActivity(activityA.Id, activityA.Name);
            dcrGraph.AddActivity(activityB.Id, activityB.Name);
            dcrGraph.AddActivity(activityF.Id, activityF.Name);
            dcrGraph.AddCondition(activityE.Id, activityF.Id); //outgoing relation
            //ingoing relation
            dcrGraph.AddCondition(activityA.Id, activityC.Id);
            dcrGraph.AddCondition(activityA.Id, activityD.Id);
            dcrGraph.AddCondition(activityA.Id, activityE.Id);

            dcrGraph.MakeNestedGraph(new HashSet<Activity>() { activityC, activityD, activityE });

            //we check that the Nested graph exists
            Assert.IsTrue(dcrGraph.Activities.Any(a => a.IsNestedGraph));
        }
コード例 #9
0
        public void TestAlwaysIncludeIncludedRedundant()
        {
            var dcrGraph = new DcrGraph();

            var activityA = new Activity("A", "somename1") { Included = true };
            var activityB = new Activity("B", "somename2") { Included = true };
            var activityC = new Activity("C", "somename3") { Included = false };
            dcrGraph.Activities.Add(activityA);
            dcrGraph.Activities.Add(activityB);
            dcrGraph.Activities.Add(activityC);
            dcrGraph.AddCondition(activityA.Id, activityB.Id);
            dcrGraph.AddIncludeExclude(true, activityB.Id, activityC.Id);
            dcrGraph.AddIncludeExclude(true, activityA.Id, activityC.Id);
            var newDcr = new RedundancyRemover().RemoveRedundancy(dcrGraph);

            //we should now have removed include b -> c. so we are asserting that B no longer has a include relation
            Assert.IsFalse(newDcr.GetIncludeOrExcludeRelation(activityB, true).Contains(activityC));
        }
コード例 #10
0
        public void RedundantRemoverWithNestedRedundantIncludes()
        {
            var dcrGraph = new DcrGraph();

            var activityA = new Activity("A", "somename1") { Included = false };
            var activityB = new Activity("B", "somename2") { Included = true };
            var activityC = new Activity("C", "somename3") { Included = true };
            var activityD = new Activity("D", "somename4") { Included = false };

            dcrGraph.AddActivities(activityA, activityB, activityC, activityD);

            dcrGraph.AddIncludeExclude(true, activityA.Id, activityB.Id);
            dcrGraph.AddIncludeExclude(true, activityA.Id, activityC.Id);
            dcrGraph.AddIncludeExclude(true, activityA.Id, activityD.Id);

            dcrGraph.MakeNestedGraph(new HashSet<Activity>() { activityB, activityC, activityD });

            dcrGraph.AddIncludeExclude(true, activityA.Id, activityB.Id); // redundant include

            var newGraph = new RedundancyRemover().RemoveRedundancy(dcrGraph);

            //we check that the (redundant) include to an activity within an included nested graph was removed
            Assert.IsFalse(newGraph.InRelation(activityB, newGraph.IncludeExcludes));
        }
コード例 #11
0
        public void TestActivityAlwaysExcludedRedundant()
        {
            var dcrGraph = new DcrGraph();

            var activityA = new Activity("A", "somename1") { Included = false };
            var activityB = new Activity("B", "somename2") { Included = true };
            var activityC = new Activity("C", "somename3") { Included = true };

            dcrGraph.Activities.Add(activityA);
            dcrGraph.Activities.Add(activityB);
            dcrGraph.Activities.Add(activityC);

            dcrGraph.AddCondition(activityA.Id, activityB.Id);
            dcrGraph.AddMileStone(activityA.Id, activityB.Id);
            dcrGraph.AddIncludeExclude(false, activityA.Id, activityC.Id);
            dcrGraph.AddResponse(activityA.Id, activityB.Id);
            dcrGraph.AddResponse(activityB.Id, activityA.Id);

            var newGraph = new RedundancyRemover().RemoveRedundancy(dcrGraph);

            //Now all the relations from or to A should be removed:");
            Assert.IsTrue(!newGraph.InRelation(activityA, newGraph.Conditions)
                && !newGraph.InRelation(activityA, newGraph.IncludeExcludes)
                && !newGraph.InRelation(activityA, newGraph.Responses)
                && !newGraph.InRelation(activityA, newGraph.Milestones));
        }
コード例 #12
0
        public void TestResponseAndExcludeRedundantIfNoTargetInclude()
        {
            var dcrGraph = new DcrGraph();

            var activityA = new Activity("A", "somename1") { Included = true };
            var activityB = new Activity("B", "somename2") { Included = true };
            dcrGraph.Activities.Add(activityA);
            dcrGraph.Activities.Add(activityB);
            dcrGraph.AddResponse(activityA.Id, activityB.Id);
            dcrGraph.AddIncludeExclude(false, activityA.Id, activityB.Id);

            var newGraph = new RedundancyRemover().RemoveRedundancy(dcrGraph);

            //Now the redundant response relation should be removed:

            Assert.IsFalse(newGraph.InRelation(activityB, newGraph.Responses));
        }
コード例 #13
0
        public void TestRedundancyRemoverExcludes()
        {
            var graph = new DcrGraph();
            graph.AddActivity("A", "somename1");
            graph.AddActivity("B", "somename2");

            graph.SetIncluded(true, "A"); // Start at A
            graph.SetIncluded(true, "B"); // Start at B

            // If you choose A - cannot do B, if you choose B, can still do A.
            graph.AddIncludeExclude(false, "A", "B");
            // Self-excludes
            //graph.AddIncludeExclude(false, "A", "A");
            //graph.AddIncludeExclude(false, "B", "B");

            Console.WriteLine(graph);

            //graph.Running = true;
            //graph.Execute(graph.GetActivity("A"));
            //graph.Execute(graph.GetActivity("C"));

            //Console.WriteLine(graph);

            Console.WriteLine("------------------");

            Console.WriteLine(new RedundancyRemover().RemoveRedundancy(graph));

            Console.ReadLine();

            // Conclusion: Edits made to not see self-exclusion as redundant
        }
コード例 #14
0
        public void CreateNestsTest()
        {
            var dcrGraph = new DcrGraph();

            var activityA = new Activity("A", "somename1") { Included = true, Pending = true };
            var activityB = new Activity("B", "somename2") { Included = true };
            var activityC = new Activity("C", "somename3") { Included = true };
            var activityD = new Activity("D", "somename4") { Included = true };
            var activityE = new Activity("E", "somename5") { Included = true, Pending = true };
            var activityF = new Activity("F", "somename6") { Included = true };
            var activityG = new Activity("G", "somename7") { Included = true };

            dcrGraph.AddActivities(activityA, activityB, activityC, activityD, activityE, activityF, activityG);

            dcrGraph.AddResponse(activityB.Id, activityC.Id); //inner nest condition

            //From A to all inner
            dcrGraph.AddIncludeExclude(false, activityA.Id, activityB.Id);
            dcrGraph.AddIncludeExclude(false, activityA.Id, activityC.Id);
            dcrGraph.AddIncludeExclude(false, activityA.Id, activityD.Id);
            dcrGraph.AddIncludeExclude(false, activityA.Id, activityE.Id);
            dcrGraph.AddIncludeExclude(false, activityA.Id, activityB.Id);

            dcrGraph.AddIncludeExclude(false, activityD.Id, activityF.Id); //from in to out
            dcrGraph.AddMileStone(activityF.Id, activityG.Id);

            //From G to all inner and F
            dcrGraph.AddCondition(activityG.Id, activityB.Id);
            dcrGraph.AddCondition(activityG.Id, activityC.Id);
            dcrGraph.AddCondition(activityG.Id, activityD.Id);
            dcrGraph.AddCondition(activityG.Id, activityE.Id);
            dcrGraph.AddCondition(activityG.Id, activityF.Id);

            var exhaust = new ContradictionApproach(dcrGraph.Activities) { Graph = dcrGraph };

            exhaust.Graph = ContradictionApproach.CreateNests(exhaust.Graph);

            Assert.IsTrue(exhaust.Graph.Activities.Any(a => a.IsNestedGraph));
        }
コード例 #15
0
        public void TestIncludesToIncludedRedundant()
        {
            var dcrGraph = new DcrGraph();

            var activityA = new Activity("A", "somename1") { Included = true };
            var activityB = new Activity("B", "somename2") { Included = true };
            dcrGraph.Activities.Add(activityA);
            dcrGraph.Activities.Add(activityB);
            dcrGraph.AddIncludeExclude(true, activityA.Id, activityB.Id);

            //Now the redundant include relation should be removed:");

            var newGraph = new RedundancyRemover().RemoveRedundancy(dcrGraph);
            Assert.IsFalse(newGraph.InRelation(activityA, newGraph.IncludeExcludes));
        }
コード例 #16
0
        public void OriginalLogStatisticsGraphMeasures()
        {
            var originalLog = new List<LogTrace>
            {
                new LogTrace('A', 'B', 'E'),
                new LogTrace('A', 'C', 'F', 'A', 'B', 'B', 'F'),
                new LogTrace('A', 'C', 'E'),
                new LogTrace('A', 'D', 'F'),
                new LogTrace('A', 'B', 'F', 'A', 'B', 'E'),
                new LogTrace('A', 'C', 'F'),
                new LogTrace('A', 'B', 'F', 'A', 'C', 'F', 'A', 'C', 'E'),
                new LogTrace('A', 'B', 'B', 'B', 'F'),
                new LogTrace('A', 'B', 'B', 'E'),
                new LogTrace('A', 'C', 'F', 'A', 'C', 'E')
            };

            var apriori = new DcrGraph();
            apriori.AddActivities(new Activity("A", "nameA"), new Activity("B", "nameB"), new Activity("C", "nameC"),
                new Activity("E", "nameE"), new Activity("F", "nameF"));
            apriori.SetIncluded(true, "A");
            apriori.SetIncluded(false, "B");
            apriori.SetIncluded(false, "C");
            apriori.SetIncluded(false, "E");
            apriori.SetIncluded(false, "F");

            apriori.AddResponse("A", "B");
            apriori.AddResponse("A", "C");
            apriori.AddResponse("A", "E");
            apriori.AddResponse("A", "F");
            apriori.AddResponse("B", "E");

            // self-excludes
            apriori.AddIncludeExclude(false, "A", "A");
            apriori.AddIncludeExclude(false, "C", "C");
            apriori.AddIncludeExclude(false, "E", "E");
            apriori.AddIncludeExclude(false, "F", "F");

            apriori.AddIncludeExclude(true, "A", "B");
            apriori.AddIncludeExclude(true, "A", "C");
            apriori.AddIncludeExclude(true, "F", "A");
            apriori.AddIncludeExclude(true, "B", "E");
            apriori.AddIncludeExclude(true, "B", "F");
            apriori.AddIncludeExclude(true, "C", "E");
            apriori.AddIncludeExclude(true, "C", "F");

            apriori.AddIncludeExclude(false, "B", "C");
            apriori.AddIncludeExclude(false, "C", "B");
            apriori.AddIncludeExclude(false, "E", "B");
            apriori.AddIncludeExclude(false, "E", "F");
            apriori.AddIncludeExclude(false, "F", "E");
            apriori.AddIncludeExclude(false, "F", "B");

            Console.WriteLine(QualityDimensionRetriever.Retrieve(apriori, new Log { Traces = originalLog }));

            Console.ReadLine();
        }
コード例 #17
0
        public void ParseMortgageApplication2()
        {
            var graph = new DcrGraph();

            graph.AddActivities(new Activity("Collect Documents", "Collect Documents") { Included = true, Roles = "Caseworker" });
            graph.AddIncludeExclude(false, "Collect Documents", "Collect Documents");

            graph.AddActivities(new Activity("Irregular neighbourhood", "Irregular neighbourhood") { Included = true, Roles = "it" });
            graph.AddIncludeExclude(false, "Irregular neighbourhood", "Irregular neighbourhood");

            graph.AddActivities(new Activity("Make appraisal appointment", "Make appraisal appointment") { Included = true, Roles = "Mobile consultant" });
            graph.AddIncludeExclude(false, "Make appraisal appointment", "Make appraisal appointment");

            graph.AddActivities(new Activity("Appraisal audit", "Appraisal audit") { Included = true, Roles = "Auditor" });
            graph.AddIncludeExclude(false, "Appraisal audit", "Appraisal audit");

            graph.AddActivities(new Activity("On-site appraisal", "On-site appraisal") { Included = true, Roles = "Mobile consulant" });
            graph.AddIncludeExclude(false, "On-site appraisal", "On-site appraisal");

            graph.AddActivities(new Activity("Submit budget", "Submit budget") { Included = true, Roles = "Customer" });
            graph.AddIncludeExclude(false, "Submit budget", "Submit budget");

            graph.AddActivities(new Activity("Budget screening approve", "Budget screening approve") { Included = true, Pending = true, Roles = "Intern" });
            graph.AddIncludeExclude(false, "Budget screening approve", "Budget screening approve");

            graph.AddActivities(new Activity("Statistical appraisal", "Statistical appraisal") { Included = true, Roles = "Caseworker" });
            graph.AddIncludeExclude(false, "Statistical appraisal", "Statistical appraisal");

            graph.AddActivities(new Activity("Assess loan application", "Assess loan application") { Included = true, Pending = true, Roles = "Caseworker" });
            graph.AddIncludeExclude(false, "Assess loan application", "Assess loan application");

            graph.AddCondition("Collect Documents", "Irregular neighbourhood");
            graph.AddCondition("Collect Documents", "Make appraisal appointment");
            graph.AddCondition("Collect Documents", "On-site appraisal");
            graph.AddCondition("Collect Documents", "Statistical appraisal");

            graph.AddIncludeExclude(false, "Statistical appraisal", "Irregular neighbourhood");
            graph.AddIncludeExclude(false, "Statistical appraisal", "Make appraisal appointment");
            graph.AddIncludeExclude(false, "Statistical appraisal", "On-site appraisal");

            graph.AddIncludeExclude(false, "Irregular neighbourhood","Statistical appraisal");
            graph.AddIncludeExclude(false, "Make appraisal appointment","Statistical appraisal" );
            graph.AddIncludeExclude(false, "On-site appraisal","Statistical appraisal");

            graph.AddCondition("Irregular neighbourhood", "Make appraisal appointment");
            graph.AddCondition("Make appraisal appointment", "On-site appraisal");
            graph.AddCondition("On-site appraisal", "Submit budget");
            graph.AddCondition("Submit budget", "Budget screening approve");
            graph.AddCondition("Budget screening approve", "Assess loan application");
            graph.AddCondition("Assess loan application","Appraisal audit");

            graph.AddCondition("Statistical appraisal", "Submit budget");

            var nested = new HashSet<Activity>();
            nested.Add(graph.GetActivity("Irregular neighbourhood"));
            nested.Add(graph.GetActivity("Make appraisal appointment"));
            nested.Add(graph.GetActivity("On-site appraisal"));

            graph.MakeNestedGraph(nested);

            //LogGenerator9001 logGenerator9001 = new LogGenerator9001(20, graph);

            //Log log = new Log();

            //foreach (var trace in logGenerator9001.GenerateLog(500))
            //{
            //    log.AddTrace(trace);
            //}

            using (StreamWriter sw = new StreamWriter("C:/Downloads/mortgageStrict.xml"))
            {
                sw.WriteLine(graph.ExportToXml());
            }
        }
コード例 #18
0
        public void GetQualityMeasuresOnStatisticsOriginalGraph()
        {
            var trace1 = new LogTrace { Id = "1" };
            trace1.AddEventsWithChars('A', 'B', 'E');
            var trace2 = new LogTrace { Id = "2" };
            trace2.AddEventsWithChars('A', 'C', 'F', 'A', 'B', 'B', 'F');
            var trace3 = new LogTrace { Id = "3" };
            trace3.AddEventsWithChars('A', 'C', 'E');
            var trace4 = new LogTrace { Id = "4" };
            trace4.AddEventsWithChars('A', 'D', 'F');
            var trace5 = new LogTrace { Id = "5" };
            trace5.AddEventsWithChars('A', 'B', 'F', 'A', 'B', 'E');
            var trace6 = new LogTrace { Id = "6" };
            trace6.AddEventsWithChars('A', 'C', 'F');
            var trace7 = new LogTrace { Id = "7" };
            trace7.AddEventsWithChars('A', 'B', 'F', 'A', 'C', 'F', 'A', 'C', 'E');
            var trace8 = new LogTrace { Id = "8" };
            trace8.AddEventsWithChars('A', 'B', 'B', 'B', 'F');
            var trace9 = new LogTrace { Id = "9" };
            trace9.AddEventsWithChars('A', 'B', 'B', 'E');
            var trace10 = new LogTrace { Id = "10" };
            trace10.AddEventsWithChars('A', 'C', 'F', 'A', 'C', 'E');

            Log log = new Log() { Traces = { trace1, trace2, trace3, trace4, trace5, trace6, trace7, trace8, trace9, trace10 } };

            var graph = new DcrGraph();
            for (char ch = 'A'; ch <= 'F'; ch++)
            {
                if (ch == 'D') continue;
                graph.AddActivity(ch.ToString(), "somename" + ch);
            }
            graph.SetIncluded(true, "A");

            // Self-excludes
            graph.AddIncludeExclude(false, "A", "A");
            graph.AddIncludeExclude(false, "C", "C");
            graph.AddIncludeExclude(false, "E", "E");
            graph.AddIncludeExclude(false, "F", "F");

            // Includes
            graph.AddIncludeExclude(true, "A", "B");
            graph.AddIncludeExclude(true, "A", "C");
            graph.AddIncludeExclude(true, "B", "E");
            graph.AddIncludeExclude(true, "B", "F");
            graph.AddIncludeExclude(true, "C", "E");
            graph.AddIncludeExclude(true, "C", "F");
            graph.AddIncludeExclude(true, "F", "A");

            // Excludes
            graph.AddIncludeExclude(false, "E", "B");
            graph.AddIncludeExclude(false, "B", "C");
            graph.AddIncludeExclude(false, "C", "B");
            graph.AddIncludeExclude(false, "F", "B");
            graph.AddIncludeExclude(false, "E", "F");
            graph.AddIncludeExclude(false, "F", "E");

            //var redundRemoved = new RedundancyRemover().RemoveRedundancy(graph);

            Console.WriteLine(QualityDimensionRetriever.Retrieve(graph, log));
            Console.ReadLine();
        }
コード例 #19
0
        public static DcrGraph ParseDreyerLog()
        {
            var graph = new DcrGraph();

            graph.AddActivities(new Activity("Execute abandon", "Execute abandon") {Included = true, Roles = "Caseworker"});

            graph.AddActivities(new Activity("Change phase to abandon", "Change phase to abandon") { Included = true, Roles = "Nobody" });

            graph.AddActivities(new Activity("Round ends", "Round ends") {Included = true, Pending = false, Roles = "it"});

            graph.AddActivities(new Activity("Fill out application", "Fill out application") { Included = true, Pending = false, Roles = "Nobody" });

            graph.AddActivities(new Activity("End", "End") { Included = true, Pending = false, Roles = "*" });

            graph.AddActivities(new Activity("Screening approve", "Screening approve") { Included = true, Pending = false, Roles = "caseworker" });
            graph.AddActivities(new Activity("File architect", "File architect") { Included = true, Pending = false, Roles = "it" });
            graph.AddActivities(new Activity("Screening reject", "Screening reject") { Included = true, Pending = false, Roles = "caseworker" });
            graph.AddActivities(new Activity("File lawyer", "File lawyer") { Included = true, Pending = false, Roles = "it" });

            graph.AddActivities(new Activity("Review 1", "Review 1") { Included = true, Pending = false, Roles = "lawyer" });
            graph.AddActivities(new Activity("Review 2", "Review 2") { Included = true, Pending = false, Roles = "architect" });
            graph.AddActivities(new Activity("Review 3", "Review 3") { Included = true, Pending = false, Roles = "lawyer" });
            graph.AddActivities(new Activity("Review 4", "Review 4") { Included = true, Pending = false, Roles = "architect" });

            graph.AddActivities(new Activity("Round approved", "Round approved") { Included = true, Pending = false, Roles = "it" });

            graph.AddActivities(new Activity("Set pre-approved", "Set pre-approved") { Included = true, Pending = false, Roles = "it" });
            graph.AddActivities(new Activity("Inform approve", "Inform approve") { Included = true, Pending = false, Roles = "casework" });
            graph.AddActivities(new Activity("Receive end report", "Receive end report") { Included = true, Pending = false, Roles = "caseworker" });

            graph.AddActivities(new Activity("Payout", "Payout") { Included = true, Pending = false, Roles = "it" });
            graph.AddActivities(new Activity("Payout complete", "Payout complete") { Included = true, Pending = false, Roles = "it" });
            graph.AddActivities(new Activity("Undo payout", "Undo payout") { Included = true, Pending = false, Roles = "caseworker" });

            graph.AddActivities(new Activity("Reject application", "Reject application") { Included = true, Pending = false, Roles = "board" });
            graph.AddActivities(new Activity("Approve application", "Approve application") { Included = true, Pending = false, Roles = "board" });
            graph.AddActivities(new Activity("Note decision", "Note decision") { Included = true, Pending = false, Roles = "caseworker" });

            graph.AddActivities(new Activity("Account no changed", "Account no changed") { Included = false, Pending = false, Roles = "it" });

            graph.AddActivities(new Activity("Approve account no", "Approve account no") { Included = true, Pending = false, Roles = "accountant" });

            graph.AddActivities(new Activity("Guard", "Guard") { Included = true, Pending = true, Roles = "*" });
            //Should abort be included???
            graph.AddActivities(new Activity("Abort application", "Abort application") { Included = false, Pending = false, Roles = "caseworker" });
            graph.AddActivities(new Activity("Inform reject", "Inform reject") { Included = false, Pending = false, Roles = "caseworker"});
            graph.AddActivities(new Activity("Purge application", "Purge application") { Included = false, Pending = false, Roles = "it" });

            graph.AddIncludeExclude(false, "File architect", "File lawyer");
            graph.AddIncludeExclude(false, "File lawyer", "File architect");

            graph.AddCondition("Approve application", "Note decision");
            graph.AddCondition("Reject application", "Note decision");

            graph.AddIncludeExclude(false, "Payout", "Payout");
            graph.AddCondition("Payout", "Undo payout");

            graph.AddIncludeExclude(true, "Undo payout", "Payout");
            graph.AddResponse("Undo payout", "Payout");

            graph.AddResponse("Payout", "Payout complete");
            graph.AddIncludeExclude(false, "Payout complete", "Undo payout");
            graph.AddMileStone("Payout", "Payout complete");

            graph.AddCondition("Abort application", "Inform reject");
            graph.AddResponse("Abort application", "Inform reject");
            graph.AddCondition("Inform reject", "Purge application");
            graph.AddResponse("Inform reject", "Purge application");

            graph.AddIncludeExclude(true, "Screening reject", "Inform reject");
            graph.AddIncludeExclude(true, "Reject application", "Inform reject");

            graph.AddIncludeExclude(false, "Screening approve", "Screening reject");

            graph.AddCondition("Screening approve", "File lawyer");
            graph.AddCondition("Screening approve", "File architect");

            graph.AddCondition("File lawyer", "Review 1");
            graph.AddCondition("File lawyer", "Review 2");
            graph.AddCondition("File lawyer", "Review 3");
            graph.AddCondition("File lawyer", "Review 4");
            graph.AddCondition("File architect", "Review 1");
            graph.AddCondition("File architect", "Review 2");
            graph.AddCondition("File architect", "Review 3");
            graph.AddCondition("File architect", "Review 4");

            graph.AddIncludeExclude(false, "File architect", "Review 1");
            graph.AddIncludeExclude(false, "File lawyer", "Review 2");

            graph.AddCondition("Fill out application", "Screening approve");
            graph.AddCondition("Fill out application", "Screening reject");
            graph.AddResponse("Fill out application", "Payout");

            graph.AddCondition("Review 3", "Approve application");
            graph.AddCondition("Review 4", "Approve application");
            graph.AddCondition("Review 3", "Reject application");
            graph.AddCondition("Review 4", "Reject application");

            graph.AddCondition("Inform approve", "Payout");
            graph.AddCondition("Inform approve", "Receive end report");
            graph.AddResponse("Approve application", "Set pre-approved");

            graph.AddIncludeExclude(true, "Set pre-approved", "Abort application");

            graph.AddCondition("Payout", "Receive end report");
            graph.AddMileStone("Payout", "Receive end report");

            graph.AddIncludeExclude(false, "Round approved", "Set pre-approved");
            graph.AddResponse("Round approved", "Approve application");
            graph.AddResponse("Round approved", "Reject application");
            graph.AddResponse("Round approved", "Set pre-approved");

            graph.AddResponse("Account no changed", "Approve account no");
            graph.AddCondition("Account no changed", "Approve account no");
            graph.AddMileStone("Approve account no", "Payout");
            graph.AddIncludeExclude(false, "Payout", "Abort application");
            graph.AddIncludeExclude(false, "Payout", "Account no changed");

            graph.AddIncludeExclude(true, "Reject application", "Inform reject");

            graph.AddCondition("Approve application", "Set pre-approved");
            graph.AddCondition("Approve application", "Inform approve");

            graph.AddIncludeExclude(false, "Inform approve", "Review 1");
            graph.AddIncludeExclude(false, "Inform approve", "Review 2");
            graph.AddIncludeExclude(false, "Inform approve", "Review 3");
            graph.AddIncludeExclude(false, "Inform approve", "Review 4");
            graph.AddIncludeExclude(false, "Inform approve", "Approve application");
            graph.AddIncludeExclude(false, "Inform approve", "Reject application");
            graph.AddIncludeExclude(false, "Inform approve", "Note decision");
            graph.AddIncludeExclude(false, "Inform approve", "Abort application");

            graph.AddCondition("Inform approve", "Payout");
            graph.AddCondition("Inform approve", "Receive end report");

            graph.AddResponse("Approve application", "Set pre-approved");
            graph.AddCondition("Payout", "Receive end report");
            graph.AddMileStone("Payout", "Receive end report");

            graph.AddResponse("Approve application", "Payout");
            graph.AddIncludeExclude(true,"Approve application", "Approve account no");
            graph.AddIncludeExclude(true, "Set pre-approved", "Approve account no");

            graph.AddIncludeExclude(false, "Receive end report", "Guard");
            graph.AddIncludeExclude(false, "Inform reject", "Guard");
            graph.AddCondition("Guard","Guard");
            graph.AddCondition("Guard", "End");

            graph.AddResponse("Fill out application","End");

            return graph;
        }
コード例 #20
0
        public void TestRedundancyRemoverLimited()
        {
            var graph = new DcrGraph();
            graph.AddActivity("A", "somename1");

            graph.SetIncluded(true, "A"); // Start at A

            graph.AddIncludeExclude(false, "A", "A");

            Console.WriteLine(graph);

            //graph.Running = true;
            //graph.Execute(graph.GetActivity("A"));
            //graph.Execute(graph.GetActivity("C"));

            //Console.WriteLine(graph);

            Console.WriteLine("------------------");

            Console.WriteLine(new RedundancyRemover().RemoveRedundancy(graph));

            Console.ReadLine();

            // Conclusion: Edits made to not see self-exclusion as redundant
        }
コード例 #21
0
        public void TestConditionMilestoneRedundancy()
        {
            var dcrGraph = new DcrGraph();

            var activityA = new Activity("A", "somename1") { Included = false };
            var activityB = new Activity("B", "somename2") { Included = true };
            var activityC = new Activity("C", "somename3") { Included = true };

            dcrGraph.Activities.Add(activityA);
            dcrGraph.Activities.Add(activityB);
            dcrGraph.Activities.Add(activityC);

            dcrGraph.AddCondition(activityA.Id, activityB.Id);
            dcrGraph.AddMileStone(activityA.Id, activityB.Id);
            dcrGraph.AddIncludeExclude(true, activityC.Id, activityA.Id);
            dcrGraph.AddResponse(activityC.Id, activityA.Id);

            var newGraph = new RedundancyRemover().RemoveRedundancy(dcrGraph);

            //Now either the redundant Condition or Milestone relation should be removed:");
            Assert.IsFalse(newGraph.InRelation(activityA, newGraph.Conditions) && newGraph.InRelation(activityA, newGraph.Milestones));
        }
コード例 #22
0
        public void TestQualityDimensionsRetriever()
        {
            var graph = new DcrGraph();
            graph.AddActivity("A", "somename1");
            graph.AddActivity("B", "somename2");
            graph.AddActivity("C", "somename3");
            //graph.AddActivity("D", "somename3");

            graph.SetIncluded(true, "A"); // Start at A

            graph.AddIncludeExclude(true, "A", "B");
            graph.AddIncludeExclude(true, "B", "C");
            graph.AddIncludeExclude(false, "C", "B");
            graph.AddResponse("B", "C");
            // Self-excludes
            graph.AddIncludeExclude(false, "A", "A");
            graph.AddIncludeExclude(false, "B", "B");
            graph.AddIncludeExclude(false, "C", "C");
            graph.AddCondition("A", "B");
            graph.AddMileStone("A", "B");

            var someLog  =
                new Log() { Traces =
                    new List<LogTrace>
                    {
                        new LogTrace('A', 'B', 'C'),
                        new LogTrace('A', 'C')
                    }
                };
            var res = QualityDimensionRetriever.Retrieve(graph, someLog);
            Console.WriteLine(graph);
            Console.WriteLine(res);

            var graph2 = new DcrGraph();
            graph2.AddActivity("A", "somename1");
            graph2.AddActivity("B", "somename2");
            graph2.AddActivity("C", "somename3");
            graph2.SetIncluded(true, "A");
            graph2.SetIncluded(true, "B");
            graph2.SetIncluded(true, "C");

            res = QualityDimensionRetriever.Retrieve(graph2, someLog);
            Console.WriteLine(graph2);
            Console.WriteLine(res);

            var graph3 = new DcrGraph();
            graph3.AddActivity("A", "somename1");
            graph3.AddActivity("B", "somename2");
            graph3.AddActivity("C", "somename3");
            graph3.AddIncludeExclude(false, "A", "A");
            graph3.AddIncludeExclude(false, "B", "B");
            graph3.AddIncludeExclude(false, "C", "C");
            graph3.AddIncludeExclude(false, "A", "B");
            graph3.AddIncludeExclude(false, "B", "A");
            graph3.AddIncludeExclude(false, "C", "A");
            graph3.AddIncludeExclude(false, "C", "B");
            graph3.AddIncludeExclude(false, "A", "C");
            graph3.AddIncludeExclude(false, "B", "C");
            graph3.AddResponse("A", "B");
            graph3.AddResponse("A", "C");
            graph3.AddResponse("B", "A");
            graph3.AddResponse("B", "C");
            graph3.AddResponse("C", "A");
            graph3.AddResponse("C", "B");
            graph3.AddCondition("A", "B");
            graph3.AddCondition("A", "C");
            graph3.AddCondition("B", "A");
            graph3.AddCondition("B", "C");
            graph3.AddCondition("C", "A");
            graph3.AddCondition("C", "B");
            graph3.AddMileStone("A", "B");
            graph3.AddMileStone("A", "C");
            graph3.AddMileStone("B", "A");
            graph3.AddMileStone("B", "C");
            graph3.AddMileStone("C", "A");
            graph3.AddMileStone("C", "B");

            res = QualityDimensionRetriever.Retrieve(graph3, someLog);
            Console.WriteLine(graph3);
            Console.WriteLine(res);

            // "Original" test log
            var activities = new HashSet<Activity>();

            for (char ch = 'A'; ch <= 'F'; ch++)
            {
                activities.Add(new Activity("" + ch, "somename " + ch));
            }

            var exAl = new ContradictionApproach(activities);

            var originalLog = new List<LogTrace>();
            originalLog.Add(new LogTrace('A', 'B', 'E'));
            originalLog.Add(new LogTrace('A', 'C', 'F', 'A', 'B', 'B', 'F'));
            originalLog.Add(new LogTrace('A', 'C', 'E'));
            originalLog.Add(new LogTrace('A', 'D', 'F'));
            originalLog.Add(new LogTrace('A', 'B', 'F', 'A', 'B', 'E'));
            originalLog.Add(new LogTrace('A', 'C', 'F'));
            originalLog.Add(new LogTrace('A', 'B', 'F', 'A', 'C', 'F', 'A', 'C', 'E'));
            originalLog.Add(new LogTrace('A', 'B', 'B', 'B', 'F'));
            originalLog.Add(new LogTrace('A', 'B', 'B', 'E'));
            originalLog.Add(new LogTrace('A', 'C', 'F', 'A', 'C', 'E'));
            exAl.AddTrace(originalLog[0]);
            exAl.AddTrace(originalLog[1]);
            exAl.AddTrace(originalLog[2]);
            exAl.AddTrace(originalLog[3]);
            exAl.AddTrace(originalLog[4]);
            exAl.AddTrace(originalLog[5]);
            exAl.AddTrace(originalLog[6]);
            exAl.AddTrace(originalLog[7]);
            exAl.AddTrace(originalLog[8]);
            exAl.AddTrace(originalLog[9]);

            var log = new Log() {Traces = originalLog};

            res = QualityDimensionRetriever.Retrieve(exAl.Graph, log);
            Console.WriteLine(exAl.Graph);
            Console.WriteLine(res);

            Console.WriteLine("Removing redundancy::::::::::::::::::::::::::::::::::");
            exAl.Graph = new RedundancyRemover().RemoveRedundancy(exAl.Graph);

            res = QualityDimensionRetriever.Retrieve(exAl.Graph, log);
            Console.WriteLine(exAl.Graph);
            Console.WriteLine(res);

            Console.ReadLine();
        }
コード例 #23
0
        public void TestIncludeConditionRedundancy()
        {
            var dcrGraph = new DcrGraph();

            var activityA = new Activity("A", "somename1") { Included = true };
            var activityB = new Activity("B", "somename2") { Included = false };
            dcrGraph.Activities.Add(activityA);
            dcrGraph.Activities.Add(activityB);
            dcrGraph.AddCondition(activityA.Id, activityB.Id);
            dcrGraph.AddIncludeExclude(true, activityA.Id, activityB.Id);

            var newGraph = new RedundancyRemover().RemoveRedundancy(dcrGraph);

            //Now the redundant condition relation from A to B should be removed:
            Assert.IsFalse(newGraph.InRelation(activityB, newGraph.Conditions));
        }
コード例 #24
0
        public void TestExportDcrGraphToXml()
        {
            var activities = new HashSet<Activity> { new Activity("A", "somename1"), new Activity("B", "somename2"), new Activity("C", "somename3") };
            var graph = new DcrGraph();

            foreach (var a in activities)
            {
                graph.AddActivity(a.Id, a.Name);
            }

            graph.SetIncluded(true, "A"); // Start at A

            graph.AddIncludeExclude(true, "A", "B");
            graph.AddIncludeExclude(true, "A", "C");
            graph.AddIncludeExclude(true, "B", "C");

            graph.AddIncludeExclude(false, "C", "B");
            graph.AddIncludeExclude(false, "A", "A");
            graph.AddIncludeExclude(false, "B", "B");
            graph.AddIncludeExclude(false, "C", "C");

            Console.WriteLine(graph);

            var xml = graph.ExportToXml();
            Console.WriteLine(xml);

            File.WriteAllText("E:/DCR2XML.xml", xml);

            Console.ReadLine();
        }
コード例 #25
0
        public void TestNonRedundantResponseIsNotRemoved2()
        {
            var dcrGraph = new DcrGraph();

            var activityA = new Activity("A", "somename1") { Included = true };
            var activityB = new Activity("B", "somename2") { Included = false };

            dcrGraph.Activities.Add(activityA);
            dcrGraph.Activities.Add(activityB);

            dcrGraph.AddResponse(activityA.Id, activityB.Id);
            dcrGraph.AddIncludeExclude(true, activityA.Id, activityB.Id);

            dcrGraph.AddIncludeExclude(false, activityA.Id, activityA.Id);
            var newGraph = new RedundancyRemover().RemoveRedundancy(dcrGraph);

            Assert.IsTrue(newGraph.InRelation(activityA, newGraph.Responses));
        }
コード例 #26
0
        public void TestFinalStateMisplacement()
        {
            var graph = new DcrGraph();
            graph.AddActivity("A", "somename1");
            graph.AddActivity("B", "somename2");
            graph.AddActivity("C", "somename3");

            graph.SetIncluded(true, "A"); // Start at A

            graph.AddIncludeExclude(true, "A", "B");
            graph.AddIncludeExclude(true, "B", "C");
            graph.AddIncludeExclude(false, "C", "B");
            graph.AddResponse("B", "C");
            // Self-excludes
            graph.AddIncludeExclude(false, "A", "A");
            graph.AddIncludeExclude(false, "B", "B");
            graph.AddIncludeExclude(false, "C", "C");

            Console.WriteLine(graph);

            var graph2 = new RedundancyRemover().RemoveRedundancy(graph);

            Console.WriteLine(graph2);

            Console.ReadLine();
        }
コード例 #27
0
        public void TestAlmostFlowerModel()
        {
            var graph = new DcrGraph();
            for (char ch = 'A'; ch <= 'Z'; ch++)
            {
                graph.Activities.Add(new Activity("" + ch, "somename " + ch) { Included = true });
            }

            graph.AddResponse("A", "B");
            graph.AddIncludeExclude(true, "B", "C");
            graph.AddIncludeExclude(true, "C", "D");
            graph.AddIncludeExclude(false,"B", "B");
            Console.WriteLine(graph);

            Console.WriteLine(new RedundancyRemover().RemoveRedundancy(graph));

            Console.ReadLine();
        }
コード例 #28
0
        //public void TestCompareTracesWithSupplied()
        //{
        //    var activities = new HashSet<Activity> { new Activity("A", "somename1"), new Activity("B", "somename2"), new Activity("C", "somename3") };
        //    var graph = new DcrGraph();
        //    foreach (var a in activities)
        //    {
        //        graph.AddActivity(a.Id, a.Name);
        //    }
        //    graph.SetIncluded(true, "A"); // Start at A
        //    graph.AddIncludeExclude(true, "A", "B");
        //    graph.AddIncludeExclude(true, "A", "C");
        //    graph.AddIncludeExclude(true, "B", "C");
        //    graph.AddIncludeExclude(false, "C", "B");
        //    graph.AddIncludeExclude(false, "A", "A");
        //    graph.AddIncludeExclude(false, "B", "B");
        //    graph.AddIncludeExclude(false, "C", "C");
        //    var unique = new UniqueTraceFinder(graph);
        //    var copy = graph.Copy(); // Verified Copy works using Activity level copying
        //    // Remove B -->+ C (Gives same traces :) )
        //    var activityB = copy.GetActivity("B");
        //    Dictionary<Activity, bool> targets;
        //    if (copy.IncludeExcludes.TryGetValue(activityB, out targets))
        //    {
        //        targets.Remove(copy.GetActivity("C"));
        //    }
        //    // Remove A -->+ C (Gives different traces :) )
        //    //var activityA = copy.GetActivity("A");
        //    //Dictionary<Activity, bool> targets;
        //    //if (copy.IncludeExcludes.TryGetValue(activityA, out targets))
        //    //{
        //    //    targets.Remove(copy.GetActivity("C"));
        //    //}
        //    Console.WriteLine(unique.CompareTracesFoundWithSupplied3(copy));
        //    Console.ReadLine();
        //    // Conclusion: I do believe it works!
        //}
        public void TestRedundancyRemover()
        {
            var activities = new HashSet<Activity> { new Activity("A", "somename1"), new Activity("B", "somename2"), new Activity("C", "somename3") };
            var graph = new DcrGraph();

            foreach (var a in activities)
            {
                graph.AddActivity(a.Id, a.Name);
            }

            graph.SetIncluded(true, "A"); // Start at A

            graph.AddIncludeExclude(true, "A", "B");
            graph.AddIncludeExclude(true, "A", "C");
            graph.AddIncludeExclude(true, "B", "C");

            graph.AddIncludeExclude(false, "C", "B");
            graph.AddIncludeExclude(false, "A", "A");
            graph.AddIncludeExclude(false, "B", "B");
            graph.AddIncludeExclude(false, "C", "C");

            Console.WriteLine(graph);

            //graph.Running = true;
            //graph.Execute(graph.GetActivity("A"));
            //graph.Execute(graph.GetActivity("C"));
            //Console.WriteLine(graph);

            Console.WriteLine("------------------");

            Console.WriteLine(new RedundancyRemover().RemoveRedundancy(graph));

            Console.ReadLine();
        }
コード例 #29
0
 private static void ParseRelations(DcrGraph graph, XDocument doc)
 {
     foreach (var condition in doc.Descendants("conditions").Elements())
     {
         graph.AddCondition(condition.Attribute("sourceId").Value, condition.Attribute("targetId").Value);
     }
     foreach (var condition in doc.Descendants("responses").Elements())
     {
         graph.AddResponse(condition.Attribute("sourceId").Value, condition.Attribute("targetId").Value);
     }
     foreach (var condition in doc.Descendants("excludes").Elements())
     {
         graph.AddIncludeExclude(false, condition.Attribute("sourceId").Value, condition.Attribute("targetId").Value);
     }
     foreach (var condition in doc.Descendants("includes").Elements())
     {
         graph.AddIncludeExclude(true, condition.Attribute("sourceId").Value, condition.Attribute("targetId").Value);
     }
     foreach (var condition in doc.Descendants("milestones").Elements())
     {
         graph.AddMileStone(condition.Attribute("sourceId").Value, condition.Attribute("targetId").Value);
     }
 }
コード例 #30
0
        public void TestCanActivityEverBeIncluded()
        {
            var graph = new DcrGraph();
            graph.AddActivity("A", "somename1");
            graph.AddActivity("B", "somename2");
            graph.AddActivity("C", "somename3");
            graph.AddActivity("D", "somename3");

            graph.SetIncluded(true, "A"); // Start at A

            graph.AddIncludeExclude(true, "A", "B");
            graph.AddIncludeExclude(true, "B", "C");
            graph.AddIncludeExclude(false, "C", "B");
            graph.AddResponse("B", "C");
            // Self-excludes
            graph.AddIncludeExclude(false, "A", "A");
            graph.AddIncludeExclude(false, "B", "B");
            graph.AddIncludeExclude(false, "C", "C");

            Console.WriteLine(graph);

            foreach (var activity in graph.Activities)
            {
                Console.WriteLine(activity.Id + " includable: " + graph.CanActivityEverBeIncluded(activity.Id));
            }

            Console.ReadLine();
        }