public void ExtractSnippetFilterContent2() { // Run the extraction FileSystemSnippetExtractor extractor = new FileSystemSnippetExtractor(); DirectoryInfoBase directoryInfoBase = fileSystem.DirectoryInfo.FromDirectoryName(fileSystem.Path.GetFullPath("Foo")); NodeSnippet snippet = extractor.Extract(directoryInfoBase, "Content2.txt") as NodeSnippet; // Assert Foo Assert.AreEqual("Foo", snippet.Node.Name); Assert.AreEqual(false, snippet.Node.IsLeaf); Assert.AreEqual(2, snippet.Node.Children.Count); // Assert Foo/Content2.txt Node foocontent2 = snippet.Node.Children["Content2.txt"]; Assert.AreEqual("Content2.txt", foocontent2.Name); Assert.AreEqual(true, foocontent2.IsLeaf); Assert.AreEqual(0, foocontent2.Children.Count); // Assert Foo/Bar Node bar = snippet.Node.Children["Bar"]; Assert.AreEqual("Bar", bar.Name); Assert.AreEqual(false, bar.IsLeaf); Assert.AreEqual(2, bar.Children.Count); // Assert Foo/Bar/Content2.txt Node barcontent2 = bar.Children["Content2.txt"]; Assert.AreEqual("Content2.txt", barcontent2.Name); Assert.AreEqual(true, barcontent2.IsLeaf); Assert.AreEqual(0, barcontent2.Children.Count); // Assert Foo/Bar/Foo Node barfoo = bar.Children["Foo"]; Assert.AreEqual("Foo", barfoo.Name); Assert.AreEqual(false, barfoo.IsLeaf); Assert.AreEqual(1, barfoo.Children.Count); // Assert Foo/Bar/Foo/Bar Node barfoobar = barfoo.Children["Bar"]; Assert.AreEqual("Bar", barfoobar.Name); Assert.AreEqual(false, barfoobar.IsLeaf); Assert.AreEqual(1, barfoobar.Children.Count); // Assert Foo/Bar/Foo/Bar/Content2.txt Node barfoobarcontent2 = barfoobar.Children["Content2.txt"]; Assert.AreEqual("Content2.txt", barfoobarcontent2.Name); Assert.AreEqual(true, barfoobarcontent2.IsLeaf); Assert.AreEqual(0, barfoobarcontent2.Children.Count); }
public void ExtractSnippetFilterMultiplePattern(string pattern) { // Run the extraction FileSystemSnippetExtractor extractor = new FileSystemSnippetExtractor(); DirectoryInfoBase directoryInfoBase = fileSystem.DirectoryInfo.FromDirectoryName(fileSystem.Path.GetFullPath(".")); NodeSnippet snippet = extractor.Extract(directoryInfoBase, pattern) as NodeSnippet; // Assert children number Assert.AreEqual(1, snippet.Node.Children.Count); // Assert A Node acontent = snippet.Node.Children["A"]; Assert.AreEqual("A", acontent.Name); Assert.AreEqual(false, acontent.IsLeaf); Assert.AreEqual(2, acontent.Children.Count); // Assert A/Content.gif Node contentgif = acontent.Children["Content.gif"]; Assert.AreEqual("Content.gif", contentgif.Name); Assert.AreEqual(true, contentgif.IsLeaf); Assert.AreEqual(0, contentgif.Children.Count); // Assert A/B Node bcontent = acontent.Children["B"]; Assert.AreEqual("B", bcontent.Name); Assert.AreEqual(false, bcontent.IsLeaf); Assert.AreEqual(1, bcontent.Children.Count); // Assert A/B/Content.jpg Node contentjpg = bcontent.Children["Content.jpg"]; Assert.AreEqual("Content.jpg", contentjpg.Name); Assert.AreEqual(true, contentjpg.IsLeaf); Assert.AreEqual(0, contentjpg.Children.Count); }
public void ExtractSnippetWrongRoot() { // Prepare the extraction FileSystemSnippetExtractor extractor = new FileSystemSnippetExtractor(); DirectoryInfoBase directoryInfoBase = fileSystem.DirectoryInfo.FromDirectoryName("FooBar"); // Run the extraction Assert.Throws( Is.TypeOf<SnippetExtractionException>().And.Message.EqualTo("Cannot find directory"), () => extractor.Extract(directoryInfoBase, null)); }
public void ExtractSnippetFilterNotFound() { // Run the extraction FileSystemSnippetExtractor extractor = new FileSystemSnippetExtractor(); DirectoryInfoBase directoryInfoBase = fileSystem.DirectoryInfo.FromDirectoryName(fileSystem.Path.GetFullPath("Foo")); NodeSnippet snippet = extractor.Extract(directoryInfoBase, "NotFound.txt") as NodeSnippet; // Assert Foo Assert.AreEqual("Foo", snippet.Node.Name); Assert.AreEqual(false, snippet.Node.IsLeaf); Assert.AreEqual(0, snippet.Node.Children.Count); }