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));
        }
        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);
        }
        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));
        }
        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));
        }
        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));
        }
        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();
        }
        public void RetrieveImageWithResponseRelationTest()
        {
            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.AddResponse(activityA.Id, activityB.Id);

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

            Assert.IsNotNull(img);
        }
        public void ParseMortgageApplication()
        {
            var graph = new DcrGraph();

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

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

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

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

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

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

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

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

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

            graph.AddCondition("Collect Documents", "Irregular neighbourhood");

            graph.AddCondition("Collect Documents", "Assess loan application");

            graph.AddIncludeExclude(true, "Irregular neighbourhood", "Make appraisal appointment");

            graph.AddIncludeExclude(false, "Irregular neighbourhood", "Statistical appraisal");

            graph.AddCondition("Make appraisal appointment", "On-site appraisal");

            graph.AddIncludeExclude(true, "Appraisal audit", "On-site appraisal");

            graph.AddIncludeExclude(false, "Statistical appraisal", "On-site appraisal");
            graph.AddCondition("Statistical appraisal", "Assess loan application");

            graph.AddIncludeExclude(false,  "On-site appraisal", "Statistical appraisal");
            graph.AddCondition("On-site appraisal", "Assess loan application");
            graph.AddCondition("Budget screening approve", "Assess loan application");

            graph.AddResponse("Budget screening approve", "Assess loan application");

            graph.AddCondition("Submit budget", "Budget screening approve");
            graph.AddResponse("Submit budget", "Budget screening approve");

            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/mortgageLog.xml"))
            {
                sw.WriteLine(Log.ExportToXml(log));
            }
        }
        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;
        }
        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();
        }
        //TODO: move to unit-test
        public void TestUnhealthyInput()
        {
            var dcrGraph = new DcrGraph();

            var activityA = new Activity("A", "somename1");
            var activityB = new Activity("B", "somename2");
            var activityC = new Activity("C", "somename3");
            dcrGraph.Activities.Add(activityA);
            dcrGraph.Activities.Add(activityB);
            dcrGraph.Activities.Add(activityC);
            dcrGraph.AddResponse(activityA.Id, activityB.Id);
            dcrGraph.AddResponse(activityB.Id, activityC.Id);
            dcrGraph.AddResponse(activityC.Id, activityA.Id);

            dcrGraph.SetPending(true,activityA.Id);

            Console.WriteLine(new RedundancyRemover().RemoveRedundancy(dcrGraph));
            Console.ReadLine();
        }
        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();
        }
Exemplo n.º 13
0
        public void GetRelationCountTest()
        {
            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);
            dcrGraph.AddIncludeExclude(false, activityB.Id, activityB.Id);
            dcrGraph.AddCondition(activityB.Id, activityC.Id);
            //non-sensical condition
            dcrGraph.AddCondition(activityB.Id, activityB.Id);
            dcrGraph.AddMileStone(activityA.Id, activityC.Id);
            dcrGraph.AddResponse(activityA.Id, activityC.Id);

            Assert.AreEqual(6, dcrGraph.GetRelationCount);
        }
        public void TestRedundantActivityIsRemoved()
        {
            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.AddResponse(activityB.Id, activityA.Id);
            var newGraph = new RedundancyRemover().RemoveRedundancy(dcrGraph);

            Assert.IsNull(newGraph.GetActivity(activityA.Id));
        }
        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();
        }
        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));
        }
        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();
        }
Exemplo n.º 18
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);
     }
 }
        public void RetrieveTest()
        {
            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 = true };

            dcrGraph.AddActivities(activityA, activityB, activityC);

            dcrGraph.AddResponse(activityB.Id, activityC.Id);

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

            Assert.IsNotNull(img);
        }