[banshee] build: require NUnit 2.5



commit 52166da19192db39f8846c7398b512347173e37e
Author: Andrés G. Aragoneses <knocte gmail com>
Date:   Tue Jan 7 01:34:21 2014 +0100

    build: require NUnit 2.5
    
    Previous commit [1] stated something which is not always true
    actually: although mono installs a mono-nunit.pc that contains
    the mono version (as opposed to NUnit version), some distros
    (like Debian/Ubuntu) have made that pc file be a symlink from
    /usr/lib/pkg-config/mono-nunit.pc to /usr/lib/pkg-config/nunit-pc.
    
    So the best thing is avoid this mess and only depend on NUnit,
    which BTW brings some nice API since version 2.5 (mono embeds
    version 2.4.8 [2]):
    
      Assert.That(actual, Is.EqualTo(expected));
    
    This API is more readable (maps better to English language) and has
    the added benefit of providing a way to never confuse again the
    parameter *actual* with *expected* that was so easy to switch by
    mistake on the older Assert.AreEqual(x,y) syntax.
    
    Some lines are added to the HACKING file about this as well, and
    the last test I wrote is converted to this syntax, as the first
    real sample to have in the codebase.
    
    [1] https://git.gnome.org/browse/banshee/commit/?id=3891ed1e5aaa7d06497525ab5bfc44110939a369
    [2] https://github.com/mono/mono/blob/master/mcs/nunit24/CommonAssemblyInfo.cs

 HACKING                                            |    5 +++++
 build/m4/shamrock/nunit.m4                         |   11 +----------
 .../Lastfm/Lastfm/Tests/LastfmRequestTests.cs      |    8 ++++----
 3 files changed, 10 insertions(+), 14 deletions(-)
---
diff --git a/HACKING b/HACKING
index b623742..7cfdb9c 100644
--- a/HACKING
+++ b/HACKING
@@ -93,6 +93,11 @@ guidelines. If code is in violation, you will be asked to reformat it.
   12. Please write `private` accessors even if the language defaults
     to it in the context you're in.
 
+  13. For tests, use the Assert.That(actual, Is.EqualTo(expected)); syntax,
+      which is more readable, and prevents you from misplacing the expected
+      parameter in the place of the actual parameter (a mistake that is very
+      usual when using the older Assert.AreEqual(,) syntax).
+
 
 .NET API Naming Guidelines
 ==========================
diff --git a/build/m4/shamrock/nunit.m4 b/build/m4/shamrock/nunit.m4
index 78f3f91..b8bfa53 100644
--- a/build/m4/shamrock/nunit.m4
+++ b/build/m4/shamrock/nunit.m4
@@ -1,7 +1,6 @@
 AC_DEFUN([SHAMROCK_CHECK_NUNIT],
 [
        NUNIT_REQUIRED=2.4.7
-       MONO_NUNIT_REQUIRED=2.4
 
        AC_ARG_ENABLE(tests, AC_HELP_STRING([--enable-tests], [Enable NUnit tests]),
                enable_tests=$enableval, enable_tests="no")
@@ -17,15 +16,7 @@ AC_DEFUN([SHAMROCK_CHECK_NUNIT],
                AM_CONDITIONAL(ENABLE_TESTS, test "x$do_tests" = "xyes")
 
                if test "x$do_tests" = "xno"; then
-                       PKG_CHECK_MODULES(NUNIT, mono-nunit >= $MONO_NUNIT_REQUIRED,
-                               do_tests="yes", do_tests="no")
-
-                       AC_SUBST(NUNIT_LIBS)
-                       AM_CONDITIONAL(ENABLE_TESTS, test "x$do_tests" = "xyes")
-
-                       if test "x$do_tests" = "xno"; then
-                               AC_MSG_WARN([Could not find nunit: tests will not be available])
-                       fi
+                       AC_MSG_WARN([Could not find nunit: tests will not be available])
                fi
        fi
 ])
diff --git a/src/Libraries/Lastfm/Lastfm/Tests/LastfmRequestTests.cs 
b/src/Libraries/Lastfm/Lastfm/Tests/LastfmRequestTests.cs
index ac7439f..3ff285e 100644
--- a/src/Libraries/Lastfm/Lastfm/Tests/LastfmRequestTests.cs
+++ b/src/Libraries/Lastfm/Lastfm/Tests/LastfmRequestTests.cs
@@ -129,15 +129,15 @@ namespace Lastfm.Tests
             string expected_without_querystring = expected.Substring (0, expected.IndexOf ("?"));
             string actual_without_querystring = actual.Substring (0, actual.IndexOf ("?"));
 
-            Assert.AreEqual (expected_without_querystring, actual_without_querystring);
+            Assert.That (actual_without_querystring, Is.EqualTo (expected_without_querystring));
 
             var expected_parameters = expected.Substring (expected.IndexOf ("?")).Split (new [] {'&'});
             var actual_parameters = new List<string> (actual.Substring (actual.IndexOf ("?")).Split (new [] 
{'&'}));
 
-            Assert.AreEqual (expected_parameters.Length, actual_parameters.Count);
+            Assert.That (actual_parameters.Count, Is.EqualTo (expected_parameters.Length));
             foreach (var expected_param in expected_parameters) {
-                Assert.IsTrue (actual_parameters.Contains (expected_param),
-                               String.Format ("URI {0} is missing parameter '{1}'", actual, expected_param));
+                Assert.That (actual_parameters.Contains (expected_param),
+                             String.Format ("URI {0} is missing parameter '{1}'", actual, expected_param));
             }
         }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]