Created
April 4, 2012 21:54
-
-
Save garuma/2305984 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestFixture] | |
public class HelpSourceTest | |
{ | |
class CheckGenerator : IDocGenerator<bool> | |
{ | |
public bool Generate (HelpSource hs, string id) | |
{ | |
if (hs == null || string.IsNullOrEmpty (id)) | |
return false; | |
if (hs.IsRawContent (id)) | |
return hs.GetText (id) != null; | |
return hs.IsGeneratedContent (id) ? hs.GetCachedText (id) != null : hs.GetCachedHelpStream (id) != null; | |
} | |
} | |
/* This test verifies that for every node in our tree that possed a PublicUrl, | |
* we can correctly access it back through RenderUrl | |
*/ | |
[Test] | |
public void ReachabilityTest () | |
{ | |
var rootTree = RootTree.LoadTree ("/home/jeremie/monodoc/"); | |
Node result; | |
var generator = new CheckGenerator (); | |
foreach (var leaf in GetLeaves (rootTree.RootNode)) { | |
Assert.IsTrue (rootTree.RenderUrl (leaf.PublicUrl, generator, out result)); | |
Assert.AreEqual (leaf, result); | |
} | |
} | |
IEnumerable<Node> GetLeaves (Node node) | |
{ | |
if (node == null) | |
yield break; | |
if (node.IsLeaf) | |
yield return node; | |
else | |
foreach (var child in node.Nodes) | |
foreach (var childLeaf in GetLeaves (child)) | |
yield return childLeaf; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment