/// <summary> /// Test on every graph type. Used to ensure that the behavior of the various markers is consistent /// </summary> /// <param name="testGraph"></param> private void TestOnGraphTypes(Action <TestGraph, DependencyAnalyzerBase <TestGraph> > testGraph) { // Test using the full logging strategy TestGraph testGraphFull = new TestGraph(); DependencyAnalyzerBase <TestGraph> analyzerFull = new DependencyAnalyzer <FullGraphLogStrategy <TestGraph>, TestGraph>(testGraphFull, null); testGraphFull.AttachToDependencyAnalyzer(analyzerFull); testGraph(testGraphFull, analyzerFull); TestGraph testGraphFirstMark = new TestGraph(); DependencyAnalyzerBase <TestGraph> analyzerFirstMark = new DependencyAnalyzer <FirstMarkLogStrategy <TestGraph>, TestGraph>(testGraphFirstMark, null); testGraphFirstMark.AttachToDependencyAnalyzer(analyzerFirstMark); testGraph(testGraphFirstMark, analyzerFirstMark); TestGraph testGraphNoLog = new TestGraph(); DependencyAnalyzerBase <TestGraph> analyzerNoLog = new DependencyAnalyzer <NoLogStrategy <TestGraph>, TestGraph>(testGraphNoLog, null); testGraphNoLog.AttachToDependencyAnalyzer(analyzerNoLog); testGraph(testGraphNoLog, analyzerNoLog); }
private void BuildGraphUsingAllTypesOfRules(TestGraph testGraph, DependencyAnalyzerBase <TestGraph> analyzer) { testGraph.SetDynamicDependencyRule((string nodeA, string nodeB) => { if (nodeA.EndsWith("*") && nodeB.StartsWith("*")) { return(new Tuple <string, string>(nodeA + nodeB, "DynamicRule")); } return(null); }); testGraph.AddConditionalRule("A**C", "B**D", "D", "A**C depends on D if B**D"); testGraph.AddStaticRule("D", "E", "D depends on E"); // Rules to ensure that there are some nodes that have multiple reasons to exist testGraph.AddStaticRule("A*", "E", "A* depends on E"); testGraph.AddStaticRule("*C", "E", "*C depends on E"); testGraph.AddRoot("A*", "A* is root"); testGraph.AddRoot("B*", "B* is root"); testGraph.AddRoot("*C", "*C is root"); testGraph.AddRoot("*D", "*D is root"); testGraph.AddRoot("A*B", "A*B is root"); List <string> results = testGraph.AnalysisResults; Assert.Contains("A*", results); Assert.Contains("B*", results); Assert.Contains("*C", results); Assert.Contains("*D", results); Assert.Contains("A*B", results); Assert.Contains("A**C", results); Assert.Contains("A**D", results); Assert.Contains("B**C", results); Assert.Contains("B**D", results); Assert.Contains("D", results); Assert.Contains("E", results); Assert.True(results.Count == 11); }