diff --git a/build/Tests.lua b/build/Tests.lua
index e45fa578..cdbfdb91 100644
--- a/build/Tests.lua
+++ b/build/Tests.lua
@@ -51,6 +51,7 @@ function SetupTestGeneratorProject(name)
{
"CppSharp.AST",
"CppSharp.Generator",
+ "CppSharp.Generator.Tests"
}
SetupParser()
@@ -110,7 +111,7 @@ function SetupTestProjectsCSharp(name, file, lib)
SetupManagedTestProject()
files { name .. ".Tests.cs" }
- links { name .. ".CSharp" }
+ links { name .. ".CSharp", "CppSharp.Generator.Tests" }
dependson { name .. ".Native" }
LinkNUnit()
@@ -141,7 +142,7 @@ function SetupTestProjectsCLI(name, file, lib)
SetupManagedTestProject()
files { name .. ".Tests.cs" }
- links { name .. ".CLI" }
+ links { name .. ".CLI", "CppSharp.Generator.Tests" }
dependson { name .. ".Native" }
LinkNUnit()
diff --git a/src/Generator.Tests/HeaderTestFixture.cs b/src/Generator.Tests/ASTTestFixture.cs
similarity index 85%
rename from src/Generator.Tests/HeaderTestFixture.cs
rename to src/Generator.Tests/ASTTestFixture.cs
index 512aa3d8..e1f84ebf 100644
--- a/src/Generator.Tests/HeaderTestFixture.cs
+++ b/src/Generator.Tests/ASTTestFixture.cs
@@ -1,11 +1,10 @@
using System;
-using System.IO;
using CppSharp.AST;
using CppSharp.Utils;
namespace CppSharp.Generator.Tests
{
- public class HeaderTestFixture
+ public class ASTTestFixture
{
protected Driver Driver;
protected DriverOptions Options;
@@ -15,7 +14,7 @@ namespace CppSharp.Generator.Tests
{
Options = new DriverOptions();
- var testsPath = LibraryTest.GetTestsDirectory("Native");
+ var testsPath = GeneratorTest.GetTestsDirectory("Native");
#if OLD_PARSER
Options.IncludeDirs.Add(testsPath);
diff --git a/src/Generator/Utils/TestsUtils.cs b/src/Generator.Tests/GeneratorTest.cs
similarity index 79%
rename from src/Generator/Utils/TestsUtils.cs
rename to src/Generator.Tests/GeneratorTest.cs
index 68df4943..4bd9cc58 100644
--- a/src/Generator/Utils/TestsUtils.cs
+++ b/src/Generator.Tests/GeneratorTest.cs
@@ -2,55 +2,24 @@
using System.IO;
using CppSharp.AST;
using CppSharp.Generators;
+using NUnit.Framework;
namespace CppSharp.Utils
{
- public abstract class LibraryTest : ILibrary
+ ///
+ /// The main base class for a generator-based tests project.
+ ///
+ public abstract class GeneratorTest : ILibrary
{
readonly string name;
readonly GeneratorKind kind;
- protected LibraryTest(string name, GeneratorKind kind)
+ protected GeneratorTest(string name, GeneratorKind kind)
{
this.name = name;
this.kind = kind;
}
- public static string GetTestsDirectory(string name)
- {
- var directory = Directory.GetParent(Directory.GetCurrentDirectory());
-
- while (directory != null)
- {
- var path = Path.Combine(directory.FullName, "tests", name);
-
- if (Directory.Exists(path))
- return path;
-
- directory = directory.Parent;
- }
-
- throw new Exception(string.Format(
- "Tests directory for project '{0}' was not found", name));
- }
-
- static string GetOutputDirectory()
- {
- var directory = Directory.GetParent(Directory.GetCurrentDirectory());
-
- while (directory != null)
- {
- var path = Path.Combine(directory.FullName, "obj");
-
- if (Directory.Exists(path))
- return directory.FullName;
-
- directory = directory.Parent;
- }
-
- throw new Exception("Could not find tests output directory");
- }
-
public virtual void Setup(Driver driver)
{
var options = driver.Options;
@@ -96,5 +65,55 @@ namespace CppSharp.Utils
public virtual void SetupPasses(Driver driver)
{
}
+
+ #region Helpers
+ public static string GetTestsDirectory(string name)
+ {
+ var directory = Directory.GetParent(Directory.GetCurrentDirectory());
+
+ while (directory != null)
+ {
+ var path = Path.Combine(directory.FullName, "tests", name);
+
+ if (Directory.Exists(path))
+ return path;
+
+ directory = directory.Parent;
+ }
+
+ throw new Exception(string.Format(
+ "Tests directory for project '{0}' was not found", name));
+ }
+
+ static string GetOutputDirectory()
+ {
+ var directory = Directory.GetParent(Directory.GetCurrentDirectory());
+
+ while (directory != null)
+ {
+ var path = Path.Combine(directory.FullName, "obj");
+
+ if (Directory.Exists(path))
+ return directory.FullName;
+
+ directory = directory.Parent;
+ }
+
+ throw new Exception("Could not find tests output directory");
+ }
+ #endregion
+ }
+
+ ///
+ /// The main NUnit fixture base class for a generator-based tests project.
+ /// Provides support for a text-based test system that looks for lines
+ /// in the native test declarations that match a certain pattern, which
+ /// are used for certain kinds of tests that cannot be done with just
+ /// C# code and using the generated wrappers.
+ ///
+ [TestFixture]
+ public class GeneratorTestFixture
+ {
+
}
}
diff --git a/src/Generator.Tests/Passes/TestPasses.cs b/src/Generator.Tests/Passes/TestPasses.cs
index 555607c7..a3e946dd 100644
--- a/src/Generator.Tests/Passes/TestPasses.cs
+++ b/src/Generator.Tests/Passes/TestPasses.cs
@@ -4,7 +4,7 @@ using NUnit.Framework;
namespace CppSharp.Generator.Tests.Passes
{
[TestFixture]
- public class TestPasses : HeaderTestFixture
+ public class TestPasses : ASTTestFixture
{
private PassBuilder passBuilder;
diff --git a/tests/Basic/Basic.Tests.cs b/tests/Basic/Basic.Tests.cs
index fcc3f5b7..b9349348 100644
--- a/tests/Basic/Basic.Tests.cs
+++ b/tests/Basic/Basic.Tests.cs
@@ -1,8 +1,9 @@
-using NUnit.Framework;
+using CppSharp.Utils;
+using NUnit.Framework;
using Basic;
[TestFixture]
-public class BasicTests
+public class BasicTests : GeneratorTestFixture
{
[Test]
public void TestHello()
diff --git a/tests/Basic/Basic.cs b/tests/Basic/Basic.cs
index 876c14d3..df89f9a3 100644
--- a/tests/Basic/Basic.cs
+++ b/tests/Basic/Basic.cs
@@ -4,7 +4,7 @@ using CppSharp.Utils;
namespace CppSharp.Tests
{
- public class Basic : LibraryTest
+ public class Basic : GeneratorTest
{
public Basic(GeneratorKind kind)
: base("Basic", kind)
diff --git a/tests/CLITemp/CLITemp.Tests.cs b/tests/CLITemp/CLITemp.Tests.cs
index b9cc199e..38e0aaa4 100644
--- a/tests/CLITemp/CLITemp.Tests.cs
+++ b/tests/CLITemp/CLITemp.Tests.cs
@@ -1,8 +1,9 @@
+using CppSharp.Utils;
using NUnit.Framework;
using CLITemp;
[TestFixture]
-public class CLITests
+public class CLITests : GeneratorTestFixture
{
[Test]
public void TestTypes()
diff --git a/tests/CLITemp/CLITemp.cs b/tests/CLITemp/CLITemp.cs
index bbac2855..c8b8b784 100644
--- a/tests/CLITemp/CLITemp.cs
+++ b/tests/CLITemp/CLITemp.cs
@@ -4,7 +4,7 @@ using CppSharp.Utils;
namespace CppSharp.Tests
{
- public class CLITemp : LibraryTest
+ public class CLITemp : GeneratorTest
{
public CLITemp(GeneratorKind kind)
: base("CLITemp", kind)
diff --git a/tests/CSharpTemp/CSharpTemp.Tests.cs b/tests/CSharpTemp/CSharpTemp.Tests.cs
index 0a35f0ad..10727b18 100644
--- a/tests/CSharpTemp/CSharpTemp.Tests.cs
+++ b/tests/CSharpTemp/CSharpTemp.Tests.cs
@@ -1,11 +1,12 @@
using System;
using System.Reflection;
using CSharpTemp;
+using CppSharp.Utils;
using NUnit.Framework;
using Foo = CSharpTemp.Foo;
[TestFixture]
-public class CSharpTempTests
+public class CSharpTempTests : GeneratorTestFixture
{
[Test]
public void TestIndexer()
diff --git a/tests/CSharpTemp/CSharpTemp.cs b/tests/CSharpTemp/CSharpTemp.cs
index b84bb5d2..ea18a316 100644
--- a/tests/CSharpTemp/CSharpTemp.cs
+++ b/tests/CSharpTemp/CSharpTemp.cs
@@ -49,7 +49,7 @@ namespace CppSharp.Tests
}
}
- public class CSharpTempTests : LibraryTest
+ public class CSharpTempTests : GeneratorTest
{
public CSharpTempTests(GeneratorKind kind)
: base("CSharpTemp", kind)
diff --git a/tests/STL/STL.Tests.cs b/tests/STL/STL.Tests.cs
index 2ba88e44..6fe3eacc 100644
--- a/tests/STL/STL.Tests.cs
+++ b/tests/STL/STL.Tests.cs
@@ -1,9 +1,10 @@
using System.Collections.Generic;
using System.Linq;
+using CppSharp.Utils;
using NUnit.Framework;
[TestFixture]
-public class STLTests
+public class STLTests : GeneratorTestFixture
{
[Test]
public void TestVectors()
diff --git a/tests/STL/STL.cs b/tests/STL/STL.cs
index 5799f5db..1aea1ed7 100644
--- a/tests/STL/STL.cs
+++ b/tests/STL/STL.cs
@@ -4,7 +4,7 @@ using CppSharp.Utils;
namespace CppSharp.Tests
{
- public class STL : LibraryTest
+ public class STL : GeneratorTest
{
public STL(GeneratorKind kind)
: base("STL", kind)
diff --git a/tests/UTF16/UTF16.Tests.cs b/tests/UTF16/UTF16.Tests.cs
index 8f5221bf..bc3d49dd 100644
--- a/tests/UTF16/UTF16.Tests.cs
+++ b/tests/UTF16/UTF16.Tests.cs
@@ -1,9 +1,9 @@
-using System;
+using CppSharp.Utils;
using NUnit.Framework;
using Foo = UTF16.Foo;
[TestFixture]
-public class UTF16Tests
+public class UTF16Tests : GeneratorTestFixture
{
[Test]
public void TestFoo()
diff --git a/tests/UTF16/UTF16.cs b/tests/UTF16/UTF16.cs
index 6c6c7e55..9ea05b3a 100644
--- a/tests/UTF16/UTF16.cs
+++ b/tests/UTF16/UTF16.cs
@@ -5,7 +5,7 @@ using CppSharp.Utils;
namespace CppSharp.Tests
{
- public class UTF16Tests : LibraryTest
+ public class UTF16Tests : GeneratorTest
{
public UTF16Tests(GeneratorKind kind)
: base("UTF16", kind)
diff --git a/tests/VTables/VTables.Tests.cs b/tests/VTables/VTables.Tests.cs
index 6e932713..ee7013d9 100644
--- a/tests/VTables/VTables.Tests.cs
+++ b/tests/VTables/VTables.Tests.cs
@@ -1,4 +1,5 @@
using System;
+using CppSharp.Utils;
using NUnit.Framework;
using VTables;
@@ -12,7 +13,7 @@ public class FooDerived : Foo
}
[TestFixture]
-public class VTablesTests
+public class VTablesTests : GeneratorTestFixture
{
[Test]
public void TestFoo()
diff --git a/tests/VTables/VTables.cs b/tests/VTables/VTables.cs
index 13735ca6..a07d58e1 100644
--- a/tests/VTables/VTables.cs
+++ b/tests/VTables/VTables.cs
@@ -5,7 +5,7 @@ using CppSharp.Utils;
namespace CppSharp.Tests
{
- public class VTableTests : LibraryTest
+ public class VTableTests : GeneratorTest
{
public VTableTests(GeneratorKind kind)
: base("VTables", kind)