You've already forked linux-packaging-mono
Imported Upstream version 5.4.0.167
Former-commit-id: 5624ac747d633e885131e8349322922b6a59baaa
This commit is contained in:
parent
e49d6f06c0
commit
536cd135cc
839
external/api-doc-tools/monodoc/Test/Monodoc.Ecma/EcmaUrlTests.cs
vendored
Normal file
839
external/api-doc-tools/monodoc/Test/Monodoc.Ecma/EcmaUrlTests.cs
vendored
Normal file
File diff suppressed because it is too large
Load Diff
70
external/api-doc-tools/monodoc/Test/Monodoc.Generators/RawGeneratorTests.cs
vendored
Normal file
70
external/api-doc-tools/monodoc/Test/Monodoc.Generators/RawGeneratorTests.cs
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Xml;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
using Monodoc;
|
||||
using Monodoc.Generators;
|
||||
|
||||
namespace MonoTests.Monodoc.Generators
|
||||
{
|
||||
[TestFixture]
|
||||
public class RawGeneratorTests
|
||||
{
|
||||
RootTree rootTree;
|
||||
RawGenerator generator = new RawGenerator ();
|
||||
|
||||
[SetUp]
|
||||
public void Setup ()
|
||||
{
|
||||
rootTree = RootTree.LoadTree (GetBaseDir (), false);
|
||||
}
|
||||
|
||||
static string GetBaseDir ([CallerFilePath] string baseDir = "")
|
||||
{
|
||||
return Path.Combine (Path.GetDirectoryName (baseDir), "..", "monodoc_test");
|
||||
}
|
||||
|
||||
void AssertValidXml (string xml)
|
||||
{
|
||||
var reader = XmlReader.Create (new StringReader (xml));
|
||||
try {
|
||||
while (reader.Read ());
|
||||
} catch (Exception e) {
|
||||
Console.WriteLine (e.ToString ());
|
||||
Assert.Fail (e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
void AssertEcmaFullTypeName (string xml, string fullTypeName)
|
||||
{
|
||||
var reader = XmlReader.Create (new StringReader (xml));
|
||||
Assert.IsTrue (reader.ReadToFollowing ("Type"));
|
||||
Assert.AreEqual (fullTypeName, reader.GetAttribute ("FullName"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSimpleEcmaXml ()
|
||||
{
|
||||
var xml = rootTree.RenderUrl ("T:System.String", generator);
|
||||
Assert.IsNotNull (xml);
|
||||
Assert.That (xml, Is.Not.Empty);
|
||||
AssertValidXml (xml);
|
||||
AssertEcmaFullTypeName (xml, "System.String");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSimpleEcmaXml2 ()
|
||||
{
|
||||
var xml = rootTree.RenderUrl ("T:System.Int32", generator);
|
||||
Assert.IsNotNull (xml);
|
||||
Assert.That (xml, Is.Not.Empty);
|
||||
AssertValidXml (xml);
|
||||
AssertEcmaFullTypeName (xml, "System.Int32");
|
||||
}
|
||||
}
|
||||
}
|
||||
56
external/api-doc-tools/monodoc/Test/Monodoc.Test.csproj
vendored
Normal file
56
external/api-doc-tools/monodoc/Test/Monodoc.Test.csproj
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{1EE70E2C-A289-4C36-AD0A-3D0C6CE56615}</ProjectGuid>
|
||||
<OutputType>Library</OutputType>
|
||||
<RootNamespace>Monodoc.Test</RootNamespace>
|
||||
<AssemblyName>Monodoc.Test</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="nunit.framework, Version=3.6.1.0, Culture=neutral, PublicKeyToken=2638cd05610744eb, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\packages\NUnit.3.6.1\lib\net45\nunit.framework.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Monodoc\EcmaDocTests.cs" />
|
||||
<Compile Include="Monodoc\HelpSourceTests.cs" />
|
||||
<Compile Include="Monodoc\NodeTest.cs" />
|
||||
<Compile Include="Monodoc\RootTreeTest.cs" />
|
||||
<Compile Include="Monodoc\SettingsTest.cs" />
|
||||
<Compile Include="Monodoc\TreeTest.cs" />
|
||||
<Compile Include="Monodoc.Ecma\EcmaUrlTests.cs" />
|
||||
<Compile Include="Monodoc.Generators\RawGeneratorTests.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\monodoc.csproj">
|
||||
<Project>{6e644802-b579-4037-9809-9cf4c7172c9d}</Project>
|
||||
<Name>monodoc</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
66
external/api-doc-tools/monodoc/Test/Monodoc/EcmaDocTests.cs
vendored
Normal file
66
external/api-doc-tools/monodoc/Test/Monodoc/EcmaDocTests.cs
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
using Monodoc;
|
||||
using Monodoc.Generators;
|
||||
|
||||
namespace MonoTests.Monodoc
|
||||
{
|
||||
[TestFixture]
|
||||
public class EcmaDocTest
|
||||
{
|
||||
// Because EcmaDoc is internal and we can't use InternalsVisibleTo since test assemblies aren't
|
||||
// signed/strong-named by the build, we have to resort to reflection
|
||||
TDelegate GetTestedMethod<TDelegate> (string methodName)
|
||||
{
|
||||
var ecmaDoc = Type.GetType ("Monodoc.Providers.EcmaDoc, monodoc, PublicKey=0738eb9f132ed756");
|
||||
return (TDelegate)(object)Delegate.CreateDelegate (typeof (TDelegate), ecmaDoc.GetMethod (methodName));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CountTypeGenericArgumentsTest ()
|
||||
{
|
||||
var realCountTypeGenericArguments = GetTestedMethod<Func<string, int, int>> ("CountTypeGenericArguments");
|
||||
// Since we don't use the optional start index parameters, bypass it by wrapping the func
|
||||
Func<string, int> countTypeGenericArguments = s => realCountTypeGenericArguments (s, 0);
|
||||
|
||||
Assert.AreEqual (0, countTypeGenericArguments ("T:System.String"), "#0a");
|
||||
Assert.AreEqual (0, countTypeGenericArguments ("T:String"), "#0b");
|
||||
Assert.AreEqual (0, countTypeGenericArguments ("String"), "#0c");
|
||||
|
||||
Assert.AreEqual (1, countTypeGenericArguments ("T:System.Collections.Foo<T>"), "#1a");
|
||||
Assert.AreEqual (1, countTypeGenericArguments ("T:System.Foo<T>"), "#1b");
|
||||
Assert.AreEqual (1, countTypeGenericArguments ("T:Foo<T>"), "#1c");
|
||||
Assert.AreEqual (1, countTypeGenericArguments ("Foo<T>"), "#1d");
|
||||
|
||||
Assert.AreEqual (2, countTypeGenericArguments ("T:System.Collections.Foo<T, U>"), "#2a");
|
||||
Assert.AreEqual (2, countTypeGenericArguments ("T:System.Foo<TKey, TValue>"), "#2b");
|
||||
Assert.AreEqual (2, countTypeGenericArguments ("T:Foo<Something,Else>"), "#2c");
|
||||
Assert.AreEqual (2, countTypeGenericArguments ("Foo<TDelegate,TArray>"), "#2d");
|
||||
|
||||
Assert.AreEqual (3, countTypeGenericArguments ("T:System.Collections.Foo<T, U, V>"), "#3a");
|
||||
Assert.AreEqual (3, countTypeGenericArguments ("T:System.Foo<TKey, TValue, THash>"), "#3b");
|
||||
Assert.AreEqual (3, countTypeGenericArguments ("T:Foo<Something,Else,Really>"), "#3c");
|
||||
Assert.AreEqual (3, countTypeGenericArguments ("Foo<TDelegate,TArray,TEvent>"), "#3d");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CountTypeGenericArgumentsTest_Nested ()
|
||||
{
|
||||
var realCountTypeGenericArguments = GetTestedMethod<Func<string, int, int>> ("CountTypeGenericArguments");
|
||||
// Since we don't use the optional start index parameters, bypass it by wrapping the func
|
||||
Func<string, int> countTypeGenericArguments = s => realCountTypeGenericArguments (s, 0);
|
||||
|
||||
Assert.AreEqual (1, countTypeGenericArguments ("T:System.Collections.Foo<T[]>"), "#1a");
|
||||
Assert.AreEqual (1, countTypeGenericArguments ("T:System.Collections.Foo<IList<T>>"), "#1b");
|
||||
Assert.AreEqual (2, countTypeGenericArguments ("T:System.Collections.Foo<T, KeyValuePair<T, U>>"), "#2a");
|
||||
Assert.AreEqual (2, countTypeGenericArguments ("T:System.Collections.Foo<T, KeyValuePair<IProducerConsumerCollection<U>, IEquatable<V>>>"), "#2b");
|
||||
Assert.AreEqual (3, countTypeGenericArguments ("T:System.Collections.Foo<T, IProducerConsumerCollection<U>, IEquatable<V>>"), "#3a");
|
||||
}
|
||||
}
|
||||
}
|
||||
231
external/api-doc-tools/monodoc/Test/Monodoc/HelpSourceTests.cs
vendored
Normal file
231
external/api-doc-tools/monodoc/Test/Monodoc/HelpSourceTests.cs
vendored
Normal file
@@ -0,0 +1,231 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
using Monodoc;
|
||||
using Monodoc.Generators;
|
||||
using Monodoc.Providers;
|
||||
|
||||
// Used by ReachabilityWithCrefsTest
|
||||
// using HtmlAgilityPack;
|
||||
|
||||
namespace MonoTests.Monodoc
|
||||
{
|
||||
[TestFixture]
|
||||
public class HelpSourceTest
|
||||
{
|
||||
static string GetBaseDir ([CallerFilePath] string baseDir = "")
|
||||
{
|
||||
return Path.Combine (Path.GetDirectoryName (baseDir), "..", "monodoc_test");
|
||||
}
|
||||
|
||||
class CheckGenerator : IDocGenerator<bool>
|
||||
{
|
||||
public string LastCheckMessage { get; set; }
|
||||
|
||||
public bool Generate (HelpSource hs, string id, Dictionary<string, string> context)
|
||||
{
|
||||
LastCheckMessage = string.Format ("#1 : {0} {1}", hs, id);
|
||||
if (hs == null || string.IsNullOrEmpty (id))
|
||||
return false;
|
||||
|
||||
// Stripe the arguments parts since we don't need it
|
||||
var argIdx = id.LastIndexOf ('?');
|
||||
if (argIdx != -1)
|
||||
id = id.Substring (0, argIdx);
|
||||
|
||||
LastCheckMessage = string.Format ("#2 : {0} {1}", hs, id);
|
||||
if (hs.IsRawContent (id))
|
||||
return hs.GetText (id) != null;
|
||||
|
||||
IEnumerable<string> parts;
|
||||
if (hs.IsMultiPart (id, out parts)) {
|
||||
LastCheckMessage = string.Format ("#4 : {0} {1} ({2})", hs, id, string.Join (", ", parts));
|
||||
foreach (var partId in parts)
|
||||
if (!Generate (hs, partId, context))
|
||||
return false;
|
||||
}
|
||||
|
||||
LastCheckMessage = string.Format ("#3 : {0} {1}", hs, id);
|
||||
if (hs.IsGeneratedContent (id))
|
||||
return hs.GetCachedText (id) != null;
|
||||
else {
|
||||
var s = hs.GetCachedHelpStream (id);
|
||||
if (s != null) {
|
||||
s.Close ();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* 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 (GetBaseDir(), false);
|
||||
Node result;
|
||||
var generator = new CheckGenerator ();
|
||||
int errorCount = 0;
|
||||
int testCount = 0;
|
||||
|
||||
foreach (var leaf in GetLeaves (rootTree.RootNode)) {
|
||||
if (!rootTree.RenderUrl (leaf.PublicUrl, generator, out result) || leaf != result) {
|
||||
Console.WriteLine ("Error: {0} with HelpSource {1} ", leaf.PublicUrl, leaf.Tree.HelpSource.Name);
|
||||
errorCount++;
|
||||
}
|
||||
testCount++;
|
||||
}
|
||||
|
||||
//Assert.AreEqual (0, errorCount, errorCount + " / " + testCount.ToString ());
|
||||
|
||||
// HACK: in reality we have currently 4 known issues which are due to duplicated namespaces across
|
||||
// doc sources, something that was never supported and that we need to improve/fix at some stage
|
||||
Assert.That (errorCount, Is.LessThanOrEqualTo(4), errorCount + " / " + testCount.ToString ());
|
||||
}
|
||||
|
||||
IEnumerable<Node> GetLeaves (Node node)
|
||||
{
|
||||
if (node == null)
|
||||
yield break;
|
||||
|
||||
if (node.IsLeaf)
|
||||
yield return node;
|
||||
else {
|
||||
foreach (var child in node.ChildNodes) {
|
||||
if (!string.IsNullOrEmpty (child.Element) && !child.Element.StartsWith ("root:/"))
|
||||
yield return child;
|
||||
foreach (var childLeaf in GetLeaves (child))
|
||||
yield return childLeaf;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ReachabilityWithShortGenericNotationTest ()
|
||||
{
|
||||
var rootTree = RootTree.LoadTree (GetBaseDir(), false);
|
||||
Node result;
|
||||
var generator = new CheckGenerator ();
|
||||
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Collections.Concurrent.IProducerConsumerCollection`1", generator, out result), "#1");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Collections.Generic.Dictionary`2", generator, out result), "#2");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Action`4", generator, out result), "#3");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.EventHandler`1", generator, out result), "#4");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`5", generator, out result), "#5a");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`4", generator, out result), "#5b");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`6", generator, out result), "#5c");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`7", generator, out result), "#5d");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`3", generator, out result), "#5e");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`2", generator, out result), "#5f");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`1", generator, out result), "#5g");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`8", generator, out result), "#5h");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Func`9", generator, out result), "#5i");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Action`3", generator, out result), "#6a");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Action`2", generator, out result), "#6b");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Action`4", generator, out result), "#6c");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.IComparable`1", generator, out result), "#7");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Lazy`1", generator, out result), "#8");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Tuple`1", generator, out result), "#9a");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Tuple`2", generator, out result), "#9b");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Tuple`3", generator, out result), "#9c");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Tuple`4", generator, out result), "#9d");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Collections.Generic.Dictionary`2+ValueCollection", generator, out result), "#10");
|
||||
Assert.IsFalse (rootTree.RenderUrl ("T:System.EventHandler`2", generator, out result), "#11");
|
||||
Assert.IsFalse (rootTree.RenderUrl ("T:System.Lazy`2", generator, out result), "#12");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AspNetStyleUrlReachabilityTest ()
|
||||
{
|
||||
var rootTree = RootTree.LoadTree (GetBaseDir(), false);
|
||||
Node result;
|
||||
var generator = new CheckGenerator ();
|
||||
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Collections.Generic.Dictionary{TKey,TValue}", generator, out result), "#1");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Action{T1,T2}", generator, out result), "#2");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.EventHandler{TEventArgs}", generator, out result), "#3");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Func{T1,T2,T3,TResult}", generator, out result), "#4");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.Collections.Generic.Dictionary{TKey,TValue}+ValueCollection", generator, out result), "#5");
|
||||
Assert.IsTrue (rootTree.RenderUrl ("T:System.IComparable{T}", generator, out result), "#6");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PublicUrlOnUnattachedHelpSourceRoot ()
|
||||
{
|
||||
// Unattached help source have no root:/ URL attributed
|
||||
var hs = new EcmaHelpSource (Path.Combine (GetBaseDir(), "sources", "netdocs"), false);
|
||||
var rootTree = RootTree.LoadTree (GetBaseDir(), false);
|
||||
hs.RootTree = rootTree;
|
||||
Assert.IsNull (hs.Tree.RootNode.PublicUrl);
|
||||
var nsChildUrl = hs.Tree.RootNode.ChildNodes.First ().PublicUrl;
|
||||
Assert.IsNotNull (nsChildUrl);
|
||||
StringAssert.StartsWith ("N:", nsChildUrl);
|
||||
// Verify GetNodeTypeParent
|
||||
var typeNode = hs.Tree.RootNode.ChildNodes.First ().ChildNodes.First ();
|
||||
var metaNode = typeNode.ChildNodes.First (cn => cn.Element == "M");
|
||||
StringAssert.StartsWith (typeNode.PublicUrl, metaNode.PublicUrl);
|
||||
}
|
||||
|
||||
/*
|
||||
[Test, Ignore ("Mono documentation is full of syntax errors so we can't use it reliably for this test")]
|
||||
public void ReachabilityWithCrefsTest ()
|
||||
{
|
||||
var rootTree = RootTree.LoadTree (Path.GetFullPath (BaseDir), false);
|
||||
Node result;
|
||||
var htmlGenerator = new HtmlGenerator (null);
|
||||
var crefs = new HashSet<string> ();
|
||||
var generator = new CheckGenerator ();
|
||||
int errorCount = 0;
|
||||
|
||||
foreach (var leaf in GetLeaves (rootTree.RootNode)) {
|
||||
Dictionary<string, string> context;
|
||||
string internalId = leaf.Tree.HelpSource.GetInternalIdForUrl (leaf.PublicUrl, out result, out context);
|
||||
if (leaf.Tree.HelpSource.GetDocumentTypeForId (internalId) != DocumentType.EcmaXml)
|
||||
continue;
|
||||
|
||||
string content = null;
|
||||
if (string.IsNullOrEmpty (content = rootTree.RenderUrl (leaf.PublicUrl, htmlGenerator, out result)) || leaf != result) {
|
||||
Console.WriteLine ("Error: {0} with HelpSource {1} ", leaf.PublicUrl, leaf.Tree.HelpSource.Name);
|
||||
continue;
|
||||
}
|
||||
|
||||
HtmlDocument doc = new HtmlDocument();
|
||||
try {
|
||||
doc.LoadHtml (content);
|
||||
} catch {
|
||||
Console.WriteLine ("Couldn't load a HTML document for URL {0}", leaf.PublicUrl);
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]")) {
|
||||
var newUrl = link.Attributes["href"].Value;
|
||||
var hashIndex = newUrl.IndexOf ('#');
|
||||
if (hashIndex != -1)
|
||||
newUrl = newUrl.Substring (0, hashIndex);
|
||||
if (newUrl.Length > 1 && newUrl[1] == ':' && char.IsLetter (newUrl, 0) && char.ToLowerInvariant (newUrl[0]) != 'c')
|
||||
crefs.Add (newUrl);
|
||||
}
|
||||
|
||||
foreach (var cref in crefs) {
|
||||
if (!rootTree.RenderUrl (cref, generator, out result) || result == null) {
|
||||
Console.WriteLine ("Error with cref: `{0}'", cref);
|
||||
errorCount++;
|
||||
}
|
||||
}
|
||||
|
||||
crefs.Clear ();
|
||||
}
|
||||
|
||||
Assert.AreEqual (0, errorCount, errorCount + " / " + crefs.Count);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
42
external/api-doc-tools/monodoc/Test/Monodoc/NodeTest.cs
vendored
Normal file
42
external/api-doc-tools/monodoc/Test/Monodoc/NodeTest.cs
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
using Monodoc;
|
||||
|
||||
namespace MonoTests.Monodoc
|
||||
{
|
||||
[TestFixture]
|
||||
public class NodeTest
|
||||
{
|
||||
[Test]
|
||||
public void LegacyNodesTest_30 ()
|
||||
{
|
||||
TestLegacyNodesSameAsChildNodes ("tree-from-3-0.tree");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LegacyNodesTest_210 ()
|
||||
{
|
||||
TestLegacyNodesSameAsChildNodes ("tree-from-2-10.tree");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void LegacyNodesTest_30old ()
|
||||
{
|
||||
TestLegacyNodesSameAsChildNodes ("tree-from-3-0-old.tree");
|
||||
}
|
||||
|
||||
void TestLegacyNodesSameAsChildNodes (string treeFileName, [CallerFilePath] string baseDir = "")
|
||||
{
|
||||
var filePath = Path.Combine (Path.GetDirectoryName (baseDir), "..", "monodoc_test", "trees", treeFileName);
|
||||
|
||||
var tree = new Tree (null, filePath);
|
||||
CollectionAssert.AreEqual (tree.RootNode.ChildNodes, tree.RootNode.Nodes);
|
||||
}
|
||||
}
|
||||
}
|
||||
60
external/api-doc-tools/monodoc/Test/Monodoc/RootTreeTest.cs
vendored
Normal file
60
external/api-doc-tools/monodoc/Test/Monodoc/RootTreeTest.cs
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
using Monodoc;
|
||||
using Monodoc.Generators;
|
||||
|
||||
namespace MonoTests.Monodoc
|
||||
{
|
||||
[TestFixture]
|
||||
public class RootTreeTest
|
||||
{
|
||||
RootTree root;
|
||||
HtmlGenerator generator;
|
||||
|
||||
[SetUp]
|
||||
public void Setup ()
|
||||
{
|
||||
root = RootTree.LoadTree (GetBaseDir (), includeExternal: false);
|
||||
generator = new HtmlGenerator (defaultCache: null);
|
||||
}
|
||||
|
||||
static string GetBaseDir ([CallerFilePath] string baseDir = "")
|
||||
{
|
||||
return Path.Combine (Path.GetDirectoryName (baseDir), "..", "monodoc_test");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void RootTreePageTest ()
|
||||
{
|
||||
var content = root.RenderUrl ("root:", generator);
|
||||
Assert.IsNotNull (content);
|
||||
StringAssert.Contains ("The following documentation collections are available:", content);
|
||||
}
|
||||
|
||||
IEnumerable<Node> GetNodesWithSummaries (Node baseNode)
|
||||
{
|
||||
return baseNode.ChildNodes.Where (n => n.Element.StartsWith ("root:/")).SelectMany (n => new[] { n }.Concat (GetNodesWithSummaries (n)));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void HelpSourceSummariesTest ()
|
||||
{
|
||||
foreach (var node in GetNodesWithSummaries (root.RootNode)) {
|
||||
var content = root.RenderUrl (node.Element, generator);
|
||||
Assert.IsNotNull (content, "#1 - " + node.Element);
|
||||
if (node.ChildNodes.All (n => n.Element.StartsWith ("root:/")))
|
||||
StringAssert.Contains ("This node doesn't have a summary available", content, "#2a - " + node.Element);
|
||||
else {
|
||||
Assert.IsFalse (content.Contains ("<em>Error:</em>"), "#2b - " + node.Element);
|
||||
Assert.IsFalse (content.Contains ("This node doesn't have a summary available"), "#3b - " + node.Element);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
23
external/api-doc-tools/monodoc/Test/Monodoc/SettingsTest.cs
vendored
Normal file
23
external/api-doc-tools/monodoc/Test/Monodoc/SettingsTest.cs
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
using Monodoc;
|
||||
|
||||
namespace MonoTests.Monodoc
|
||||
{
|
||||
[TestFixture]
|
||||
public class SettingsTest
|
||||
{
|
||||
[Test]
|
||||
public void DocPathConfigTest ()
|
||||
{
|
||||
// the docPath variable is the only one we know for sure should exist
|
||||
Assert.IsNotNull (Config.Get ("docPath"));
|
||||
Assert.That (Config.Get ("docPath"), Is.Not.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
44
external/api-doc-tools/monodoc/Test/Monodoc/TreeTest.cs
vendored
Normal file
44
external/api-doc-tools/monodoc/Test/Monodoc/TreeTest.cs
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
using NUnit.Framework;
|
||||
|
||||
using Monodoc;
|
||||
|
||||
namespace MonoTests.Monodoc
|
||||
{
|
||||
[TestFixture]
|
||||
public class TreeTest
|
||||
{
|
||||
[Test]
|
||||
public void TestLoadingTree_2_10 ()
|
||||
{
|
||||
TestTreeLoading ("tree-from-2-10.tree", 0, 2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLoadingTree_3_0_old ()
|
||||
{
|
||||
TestTreeLoading ("tree-from-3-0-old.tree", 1, 2);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLoadingTree_3_0 ()
|
||||
{
|
||||
TestTreeLoading ("tree-from-3-0.tree", 1, 2);
|
||||
}
|
||||
|
||||
void TestTreeLoading (string treeFileName, int expectedVersion, int expectedNodeCount, [CallerFilePath] string baseDir = "")
|
||||
{
|
||||
var filePath = Path.Combine (Path.GetDirectoryName (baseDir), "..", "monodoc_test", "trees", treeFileName);
|
||||
|
||||
var tree = new Tree (null, filePath);
|
||||
Assert.AreEqual (expectedVersion, tree.VersionNumber);
|
||||
Assert.IsNotNull (tree.RootNode);
|
||||
Assert.AreEqual (expectedNodeCount, tree.RootNode.ChildNodes.Count);
|
||||
}
|
||||
}
|
||||
}
|
||||
1
external/api-doc-tools/monodoc/Test/monodoc_test/.gitignore
vendored
Normal file
1
external/api-doc-tools/monodoc/Test/monodoc_test/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
/sources
|
||||
7
external/api-doc-tools/monodoc/Test/monodoc_test/monodoc.xml
vendored
Normal file
7
external/api-doc-tools/monodoc/Test/monodoc_test/monodoc.xml
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<node label="Mono Documentation" name="libraries">
|
||||
<node label="Commands and Files" name="man" />
|
||||
<node label="Languages" name="languages" />
|
||||
<node label="Tools" name="tools" />
|
||||
<node label="Various" name="various" />
|
||||
</node>
|
||||
5
external/api-doc-tools/monodoc/Test/monodoc_test/sources/netdocs.source
vendored
Normal file
5
external/api-doc-tools/monodoc/Test/monodoc_test/sources/netdocs.source
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0"?>
|
||||
<monodoc>
|
||||
<node label="Base Class Library" name="classlib" parent="libraries" />
|
||||
<source provider="ecma" basefile="netdocs" path="classlib"/>
|
||||
</monodoc>
|
||||
1
external/api-doc-tools/monodoc/Test/monodoc_test/sources/netdocs.tree.REMOVED.git-id
vendored
Normal file
1
external/api-doc-tools/monodoc/Test/monodoc_test/sources/netdocs.tree.REMOVED.git-id
vendored
Normal file
@@ -0,0 +1 @@
|
||||
8ef6521f28c87bfbef03fe2606deadc950f07561
|
||||
1
external/api-doc-tools/monodoc/Test/monodoc_test/sources/netdocs.zip.REMOVED.git-id
vendored
Normal file
1
external/api-doc-tools/monodoc/Test/monodoc_test/sources/netdocs.zip.REMOVED.git-id
vendored
Normal file
@@ -0,0 +1 @@
|
||||
8e0078f7db7bd6310a22a542aec636c7642d4f8c
|
||||
BIN
external/api-doc-tools/monodoc/Test/monodoc_test/trees/tree-from-2-10.tree
vendored
Normal file
BIN
external/api-doc-tools/monodoc/Test/monodoc_test/trees/tree-from-2-10.tree
vendored
Normal file
Binary file not shown.
BIN
external/api-doc-tools/monodoc/Test/monodoc_test/trees/tree-from-3-0-old.tree
vendored
Normal file
BIN
external/api-doc-tools/monodoc/Test/monodoc_test/trees/tree-from-3-0-old.tree
vendored
Normal file
Binary file not shown.
BIN
external/api-doc-tools/monodoc/Test/monodoc_test/trees/tree-from-3-0.tree
vendored
Normal file
BIN
external/api-doc-tools/monodoc/Test/monodoc_test/trees/tree-from-3-0.tree
vendored
Normal file
Binary file not shown.
4
external/api-doc-tools/monodoc/Test/packages.config
vendored
Normal file
4
external/api-doc-tools/monodoc/Test/packages.config
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="NUnit" version="3.6.1" targetFramework="net45" />
|
||||
</packages>
|
||||
Reference in New Issue
Block a user