diff options
author | Marek Safar <marek.safar@gmail.com> | 2017-04-21 17:11:16 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2017-04-22 11:35:13 +0300 |
commit | 593695a69b9ee2f71c0c03a106d122da27c54a6a (patch) | |
tree | 5aede87a475c99891fab2a33ed8b6dca46ecd41b /monodoc | |
parent | 1b7a9ee2e40264eb2eb5ec8e9b53403e15b812db (diff) |
Fixes tests to work with mono master again
Diffstat (limited to 'monodoc')
-rw-r--r-- | monodoc/Test/Monodoc.Generators/RawGeneratorTests.cs | 25 | ||||
-rw-r--r-- | monodoc/Test/Monodoc/HelpSourceTests.cs | 25 | ||||
-rw-r--r-- | monodoc/Test/Monodoc/NodeTest.cs | 19 | ||||
-rw-r--r-- | monodoc/Test/Monodoc/RootTreeTest.cs | 21 | ||||
-rw-r--r-- | monodoc/Test/Monodoc/SettingsTest.cs | 2 | ||||
-rw-r--r-- | monodoc/Test/Monodoc/TreeTest.cs | 19 |
6 files changed, 34 insertions, 77 deletions
diff --git a/monodoc/Test/Monodoc.Generators/RawGeneratorTests.cs b/monodoc/Test/Monodoc.Generators/RawGeneratorTests.cs index db68971f..0493c19b 100644 --- a/monodoc/Test/Monodoc.Generators/RawGeneratorTests.cs +++ b/monodoc/Test/Monodoc.Generators/RawGeneratorTests.cs @@ -3,6 +3,7 @@ using System.IO; using System.Linq; using System.Xml; using System.Collections.Generic; +using System.Runtime.CompilerServices; using NUnit.Framework; @@ -14,26 +15,18 @@ namespace MonoTests.Monodoc.Generators [TestFixture] public class RawGeneratorTests { - string BaseDir - { - get - { - var baseDir = "../../monodoc_test/"; - var assemblyLocation = this.GetType ().Assembly.Location; - return Path.GetFullPath ( - Path.Combine ( - Path.GetDirectoryName (assemblyLocation), - baseDir)); - } - } - RootTree rootTree; RawGenerator generator = new RawGenerator (); [SetUp] public void Setup () { - rootTree = RootTree.LoadTree (BaseDir, false); + rootTree = RootTree.LoadTree (GetBaseDir (), false); + } + + static string GetBaseDir ([CallerFilePath] string baseDir = "") + { + return Path.Combine (Path.GetDirectoryName (baseDir), "..", "monodoc_test"); } void AssertValidXml (string xml) @@ -59,7 +52,7 @@ namespace MonoTests.Monodoc.Generators { var xml = rootTree.RenderUrl ("T:System.String", generator); Assert.IsNotNull (xml); - Assert.IsNotEmpty (xml); + Assert.That (xml, Is.Not.Empty); AssertValidXml (xml); AssertEcmaFullTypeName (xml, "System.String"); } @@ -69,7 +62,7 @@ namespace MonoTests.Monodoc.Generators { var xml = rootTree.RenderUrl ("T:System.Int32", generator); Assert.IsNotNull (xml); - Assert.IsNotEmpty (xml); + Assert.That (xml, Is.Not.Empty); AssertValidXml (xml); AssertEcmaFullTypeName (xml, "System.Int32"); } diff --git a/monodoc/Test/Monodoc/HelpSourceTests.cs b/monodoc/Test/Monodoc/HelpSourceTests.cs index 675c31cd..0884cd50 100644 --- a/monodoc/Test/Monodoc/HelpSourceTests.cs +++ b/monodoc/Test/Monodoc/HelpSourceTests.cs @@ -2,6 +2,7 @@ using System; using System.IO; using System.Linq; using System.Collections.Generic; +using System.Runtime.CompilerServices; using NUnit.Framework; @@ -17,17 +18,9 @@ namespace MonoTests.Monodoc [TestFixture] public class HelpSourceTest { - string BaseDir + static string GetBaseDir ([CallerFilePath] string baseDir = "") { - get - { - var baseDir = "../../monodoc_test/"; - var assemblyLocation = this.GetType ().Assembly.Location; - return Path.GetFullPath ( - Path.Combine ( - Path.GetDirectoryName (assemblyLocation), - baseDir)); - } + return Path.Combine (Path.GetDirectoryName (baseDir), "..", "monodoc_test"); } class CheckGenerator : IDocGenerator<bool> @@ -78,7 +71,7 @@ namespace MonoTests.Monodoc [Test] public void ReachabilityTest () { - var rootTree = RootTree.LoadTree (BaseDir, false); + var rootTree = RootTree.LoadTree (GetBaseDir(), false); Node result; var generator = new CheckGenerator (); int errorCount = 0; @@ -96,7 +89,7 @@ namespace MonoTests.Monodoc // 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.LessOrEqual (4, errorCount, errorCount + " / " + testCount.ToString ()); + Assert.That (errorCount, Is.LessThanOrEqualTo(4), errorCount + " / " + testCount.ToString ()); } IEnumerable<Node> GetLeaves (Node node) @@ -119,7 +112,7 @@ namespace MonoTests.Monodoc [Test] public void ReachabilityWithShortGenericNotationTest () { - var rootTree = RootTree.LoadTree (BaseDir, false); + var rootTree = RootTree.LoadTree (GetBaseDir(), false); Node result; var generator = new CheckGenerator (); @@ -153,7 +146,7 @@ namespace MonoTests.Monodoc [Test] public void AspNetStyleUrlReachabilityTest () { - var rootTree = RootTree.LoadTree (BaseDir, false); + var rootTree = RootTree.LoadTree (GetBaseDir(), false); Node result; var generator = new CheckGenerator (); @@ -169,8 +162,8 @@ namespace MonoTests.Monodoc public void PublicUrlOnUnattachedHelpSourceRoot () { // Unattached help source have no root:/ URL attributed - var hs = new EcmaHelpSource (Path.Combine (BaseDir, "sources", "netdocs"), false); - var rootTree = RootTree.LoadTree (BaseDir, false); + 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; diff --git a/monodoc/Test/Monodoc/NodeTest.cs b/monodoc/Test/Monodoc/NodeTest.cs index b3a96cdd..30a54d60 100644 --- a/monodoc/Test/Monodoc/NodeTest.cs +++ b/monodoc/Test/Monodoc/NodeTest.cs @@ -2,6 +2,7 @@ using System; using System.IO; using System.Linq; using System.Collections.Generic; +using System.Runtime.CompilerServices; using NUnit.Framework; @@ -12,19 +13,6 @@ namespace MonoTests.Monodoc [TestFixture] public class NodeTest { - string BaseDir - { - get - { - var baseDir = "../../monodoc_test/"; - var assemblyLocation = this.GetType ().Assembly.Location; - return Path.GetFullPath ( - Path.Combine ( - Path.GetDirectoryName (assemblyLocation), - baseDir)); - } - } - [Test] public void LegacyNodesTest_30 () { @@ -43,9 +31,10 @@ namespace MonoTests.Monodoc TestLegacyNodesSameAsChildNodes ("tree-from-3-0-old.tree"); } - void TestLegacyNodesSameAsChildNodes (string treeFileName) + void TestLegacyNodesSameAsChildNodes (string treeFileName, [CallerFilePath] string baseDir = "") { - var filePath = Path.Combine (BaseDir, "trees", treeFileName); + 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); } diff --git a/monodoc/Test/Monodoc/RootTreeTest.cs b/monodoc/Test/Monodoc/RootTreeTest.cs index 064dc24f..16bc8e49 100644 --- a/monodoc/Test/Monodoc/RootTreeTest.cs +++ b/monodoc/Test/Monodoc/RootTreeTest.cs @@ -2,6 +2,7 @@ using System; using System.IO; using System.Linq; using System.Collections.Generic; +using System.Runtime.CompilerServices; using NUnit.Framework; @@ -13,29 +14,21 @@ namespace MonoTests.Monodoc [TestFixture] public class RootTreeTest { - string BaseDir - { - get - { - var baseDir = "../../monodoc_test/"; - var assemblyLocation = this.GetType().Assembly.Location; - return Path.GetFullPath( - Path.Combine( - Path.GetDirectoryName(assemblyLocation), - baseDir)); - } - } - RootTree root; HtmlGenerator generator; [SetUp] public void Setup () { - root = RootTree.LoadTree (BaseDir, includeExternal: false); + 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 () { diff --git a/monodoc/Test/Monodoc/SettingsTest.cs b/monodoc/Test/Monodoc/SettingsTest.cs index 29ac108d..9f935d9a 100644 --- a/monodoc/Test/Monodoc/SettingsTest.cs +++ b/monodoc/Test/Monodoc/SettingsTest.cs @@ -17,7 +17,7 @@ namespace MonoTests.Monodoc { // the docPath variable is the only one we know for sure should exist Assert.IsNotNull (Config.Get ("docPath")); - Assert.IsNotEmpty (Config.Get ("docPath")); + Assert.That (Config.Get ("docPath"), Is.Not.Empty); } } } diff --git a/monodoc/Test/Monodoc/TreeTest.cs b/monodoc/Test/Monodoc/TreeTest.cs index c2d1155b..531ae47d 100644 --- a/monodoc/Test/Monodoc/TreeTest.cs +++ b/monodoc/Test/Monodoc/TreeTest.cs @@ -2,6 +2,7 @@ using System; using System.IO; using System.Linq; using System.Collections.Generic; +using System.Runtime.CompilerServices; using NUnit.Framework; @@ -12,19 +13,6 @@ namespace MonoTests.Monodoc [TestFixture] public class TreeTest { - string BaseDir - { - get - { - var baseDir = "../../monodoc_test/"; - var assemblyLocation = this.GetType ().Assembly.Location; - return Path.GetFullPath ( - Path.Combine ( - Path.GetDirectoryName (assemblyLocation), - baseDir)); - } - } - [Test] public void TestLoadingTree_2_10 () { @@ -43,9 +31,10 @@ namespace MonoTests.Monodoc TestTreeLoading ("tree-from-3-0.tree", 1, 2); } - void TestTreeLoading (string treeFileName, int expectedVersion, int expectedNodeCount) + void TestTreeLoading (string treeFileName, int expectedVersion, int expectedNodeCount, [CallerFilePath] string baseDir = "") { - var filePath = Path.Combine (BaseDir, "trees", treeFileName); + 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); |