4 using System.Collections.Generic;
10 namespace MonoTests.Monodoc
13 public class HelpSourceTest
15 const string BaseDir = "../../class/monodoc/Test/monodoc_test/";
17 class CheckGenerator : IDocGenerator<bool>
19 public string LastCheckMessage { get; set; }
21 public bool Generate (HelpSource hs, string id, Dictionary<string, string> context)
23 LastCheckMessage = string.Format ("#1 : {0} {1}", hs, id);
24 if (hs == null || string.IsNullOrEmpty (id))
27 // Stripe the arguments parts since we don't need it
28 var argIdx = id.LastIndexOf ('?');
30 id = id.Substring (0, argIdx);
32 LastCheckMessage = string.Format ("#2 : {0} {1}", hs, id);
33 if (hs.IsRawContent (id))
34 return hs.GetText (id) != null;
36 IEnumerable<string> parts;
37 if (hs.IsMultiPart (id, out parts)) {
38 LastCheckMessage = string.Format ("#4 : {0} {1} ({2})", hs, id, string.Join (", ", parts));
39 foreach (var partId in parts)
40 if (!Generate (hs, partId, context))
44 LastCheckMessage = string.Format ("#3 : {0} {1}", hs, id);
45 if (hs.IsGeneratedContent (id))
46 return hs.GetCachedText (id) != null;
48 var s = hs.GetCachedHelpStream (id);
59 /* This test verifies that for every node in our tree that possed a PublicUrl,
60 * we can correctly access it back through RenderUrl
63 public void ReachabilityTest ()
65 var rootTree = RootTree.LoadTree (Path.GetFullPath (BaseDir), false);
67 var generator = new CheckGenerator ();
71 foreach (var leaf in GetLeaves (rootTree.RootNode)) {
72 if (!rootTree.RenderUrl (leaf.PublicUrl, generator, out result) || leaf != result) {
73 Console.WriteLine ("Error: {0} with HelpSource {1} ", leaf.PublicUrl, leaf.Tree.HelpSource.Name);
79 Assert.AreEqual (0, errorCount, errorCount + " / " + testCount.ToString ());
82 IEnumerable<Node> GetLeaves (Node node)
90 foreach (var child in node.ChildNodes) {
91 if (!string.IsNullOrEmpty (child.Element) && !child.Element.StartsWith ("root:/"))
93 foreach (var childLeaf in GetLeaves (child))
94 yield return childLeaf;
100 public void ReachabilityWithShortGenericNotationTest ()
102 var rootTree = RootTree.LoadTree (Path.GetFullPath (BaseDir), false);
104 var generator = new CheckGenerator ();
106 Assert.IsTrue (rootTree.RenderUrl ("T:System.Collections.Concurrent.IProducerConsumerCollection`1", generator, out result), "#1");
107 Assert.IsTrue (rootTree.RenderUrl ("T:System.Collections.Generic.Dictionary`2", generator, out result), "#2");
108 Assert.IsTrue (rootTree.RenderUrl ("T:System.Action`4", generator, out result), "#3");