public void RetrieveImageWithMilestoneRelationTest()
        {
            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.AddMileStone(activityA.Id, activityB.Id);

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

            Assert.IsNotNull(img);
        }
Пример #2
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 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 TestNonRedundantMilestoneIsNotRemoved()
        {
            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, activityC.Id);
            dcrGraph.AddMileStone(activityC.Id, activityA.Id);
            dcrGraph.AddIncludeExclude(true, activityB.Id, activityA.Id);
            var newGraph = new RedundancyRemover().RemoveRedundancy(dcrGraph);

            Assert.IsTrue(newGraph.InRelation(activityC, newGraph.Milestones));
        }
        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 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 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();
        }
        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);
        }