summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2017-07-03 19:05:55 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2017-07-05 21:54:40 -0300
commit865a56dcce1de09383207b45c503f55d2ef18519 (patch)
tree7e6d40031b14255a4ee0c7b7d5af6dd5d8983dbf
parent518e44b8dad64eb0baee79b23e65d1a8f09d6e19 (diff)
downloadefl-865a56dcce1de09383207b45c503f55d2ef18519.tar.gz
mono: Move test utilities into its own file.
Separate assertion utilities from test discovery and running.
-rw-r--r--src/Makefile_Efl_Mono.am4
-rw-r--r--src/tests/efl_mono/Main.cs51
-rw-r--r--src/tests/efl_mono/TestUtils.cs55
3 files changed, 58 insertions, 52 deletions
diff --git a/src/Makefile_Efl_Mono.am b/src/Makefile_Efl_Mono.am
index e917705bbe..4a891702cf 100644
--- a/src/Makefile_Efl_Mono.am
+++ b/src/Makefile_Efl_Mono.am
@@ -190,7 +190,9 @@ tests_efl_mono_efl_mono_exe_SOURCES = \
tests/efl_mono/Evas.cs \
tests/efl_mono/Events.cs \
tests/efl_mono/FunctionPointers.cs \
- tests/efl_mono/Strings.cs
+ tests/efl_mono/Strings.cs \
+ tests/efl_mono/TestUtils.cs
+
tests/efl_mono/efl_mono.exe$(EXEEXT): $(tests_efl_mono_efl_mono_exe_SOURCES) tests/efl_mono/$(am__dirstamp) lib/efl_mono/libefl_mono.dll tests/efl_mono/libefl_mono_test.dll
@rm -f tests/efl_mono/efl_mono_exe$(EXEEXT)
diff --git a/src/tests/efl_mono/Main.cs b/src/tests/efl_mono/Main.cs
index 71ef39ecc1..a1ea83fecb 100644
--- a/src/tests/efl_mono/Main.cs
+++ b/src/tests/efl_mono/Main.cs
@@ -4,57 +4,6 @@ using System.Runtime.CompilerServices;
using System.Reflection;
using System.Linq;
-public class Test
-{
- public static void Assert(bool res, String msg = "Assertion failed",
- [CallerLineNumber] int line = 0,
- [CallerFilePath] string file = null,
- [CallerMemberName] string member = null)
- {
- if (!res)
- throw new Exception($"Assertion failed: {file}:{line} ({member}) {msg}");
- }
-
- public static void AssertEquals<T>(T expected, T actual, String msg = "",
- [CallerLineNumber] int line = 0,
- [CallerFilePath] string file = null,
- [CallerMemberName] string member = null) where T : System.IComparable<T>
- {
- if (expected.CompareTo(actual) != 0) {
- if (msg == "")
- msg = $"Expected \"{expected}\", actual \"{actual}\"";
- throw new Exception($"{file}:{line} ({member}) {msg}");
- }
- }
-
- public delegate void Operation();
-
- public static void AssertRaises<T>(Operation op, String msg = "Exception not raised",
- [CallerLineNumber] int line = 0,
- [CallerFilePath] string file = null,
- [CallerMemberName] string member = null) where T: Exception
- {
- try {
- op();
- } catch (T) {
- return;
- }
- throw new Exception($"Assertion failed: {file}:{line} ({member}) {msg}");
- }
-
- public static void AssertNotRaises<T>(Operation op, String msg = "Exception raised.",
- [CallerLineNumber] int line = 0,
- [CallerFilePath] string file = null,
- [CallerMemberName] string member = null) where T: Exception
- {
- try {
- op();
- } catch (T) {
- throw new Exception($"Assertion failed: {file}:{line} ({member}) {msg}");
- }
- }
-}
-
class TestMain
{
static Type[] GetTestCases(String name="")
diff --git a/src/tests/efl_mono/TestUtils.cs b/src/tests/efl_mono/TestUtils.cs
new file mode 100644
index 0000000000..459394bf2d
--- /dev/null
+++ b/src/tests/efl_mono/TestUtils.cs
@@ -0,0 +1,55 @@
+using System;
+using System.Runtime.CompilerServices;
+
+public class Test
+{
+ public static void Assert(bool res, String msg = "Assertion failed",
+ [CallerLineNumber] int line = 0,
+ [CallerFilePath] string file = null,
+ [CallerMemberName] string member = null)
+ {
+ if (!res)
+ throw new Exception($"Assertion failed: {file}:{line} ({member}) {msg}");
+ }
+
+ public static void AssertEquals<T>(T expected, T actual, String msg = "",
+ [CallerLineNumber] int line = 0,
+ [CallerFilePath] string file = null,
+ [CallerMemberName] string member = null) where T : System.IComparable<T>
+ {
+ if (expected.CompareTo(actual) != 0) {
+ if (msg == "")
+ msg = $"Expected \"{expected}\", actual \"{actual}\"";
+ throw new Exception($"{file}:{line} ({member}) {msg}");
+ }
+ }
+
+ public delegate void Operation();
+
+ public static void AssertRaises<T>(Operation op, String msg = "Exception not raised",
+ [CallerLineNumber] int line = 0,
+ [CallerFilePath] string file = null,
+ [CallerMemberName] string member = null) where T: Exception
+ {
+ try {
+ op();
+ } catch (T) {
+ return;
+ }
+ throw new Exception($"Assertion failed: {file}:{line} ({member}) {msg}");
+ }
+
+ public static void AssertNotRaises<T>(Operation op, String msg = "Exception raised.",
+ [CallerLineNumber] int line = 0,
+ [CallerFilePath] string file = null,
+ [CallerMemberName] string member = null) where T: Exception
+ {
+ try {
+ op();
+ } catch (T) {
+ throw new Exception($"Assertion failed: {file}:{line} ({member}) {msg}");
+ }
+ }
+}
+
+