[Mono-devel-list] Upgrading of NUnit 1.x tests

Martin Willemoes Hansen mwh at sysrq.dk
Tue Mar 11 05:57:14 EST 2003


On Tue, 2003-03-11 at 09:36, Martin Willemoes Hansen wrote:

> Yesterday I also converted the tests in the Mono.Directory.LDAP
> assembly, unfortunetly I cannot compile that assembly and thus I cannot
> test the new unit tests :( I have attached them for review.
> 
> I renamed QueryRootDSE.cs to QueryRootDSETest.cs.

Okay I worked Mono.Directory.LDAP through a little more.

1. Fixed some castings of null to object in LDAP.cs to get the assembly
to compile.

2. Fixed the makefile.gnu's 

Questions:
1. NUnit.Prefs seems to do nothing, should it be removed?
2. I can compile the test assembly but I cant seem to run it, when I do
   make -f makefile.gnu test I just get this result:
	make: Nothing to be done for `test'.


-- 
Martin Willemoes Hansen

--------------------------------------------------------
E-Mail	mwh at sysrq.dk	Website	mwh.sysrq.dk
IRC     MWH, freenode.net	
--------------------------------------------------------               
-------------- next part --------------
Index: makefile.gnu
===================================================================
RCS file: /cvs/public/mcs/class/Mono.Directory.LDAP/makefile.gnu,v
retrieving revision 1.1
diff -u -r1.1 makefile.gnu
--- makefile.gnu	16 Sep 2002 21:26:14 -0000	1.1
+++ makefile.gnu	11 Mar 2003 11:01:26 -0000
@@ -1,14 +1,14 @@
 topdir = ../..
 
-LIBRARY = ../lib/Mono.Directory.LDAP.dll
+TEST_DIR= Test
+LIBRARY = $(topdir)/class/lib/Mono.Directory.LDAP.dll
 
 LIB_LIST = list
 LIB_FLAGS = -r corlib -r System -r System.Data -r mscorlib
 
 SOURCES_INCLUDE=*.cs
-SOURCES_EXCLUDE=\
-	./Test*
+SOURCES_EXCLUDE=./Test*
 
-export MONO_PATH_PREFIX = ../lib:
+export MONO_PATH_PREFIX = $(topdir)/class/lib:
 
-include ../library.make
+include $(topdir)/class/library.make
Index: Mono.Directory.LDAP/LDAP.cs
===================================================================
RCS file: /cvs/public/mcs/class/Mono.Directory.LDAP/Mono.Directory.LDAP/LDAP.cs,v
retrieving revision 1.1
diff -u -r1.1 LDAP.cs
--- Mono.Directory.LDAP/LDAP.cs	16 Sep 2002 21:26:14 -0000	1.1
+++ Mono.Directory.LDAP/LDAP.cs	11 Mar 2003 11:01:26 -0000
@@ -61,7 +61,7 @@
 
 		public int StartTLS () {
 			// FIXME should expose client/server ctrls
-			return ldap_start_tls_s (ld, (IntPtr)null, (IntPtr)null);
+			return ldap_start_tls_s (ld, IntPtr.Zero, IntPtr.Zero);
 		}
 
 		public int Search (string      base_entry,
@@ -92,10 +92,9 @@
 		  return rv;
 		}
 				   
-
 		public void Unbind () {
 			// FIXME should expose client/server ctrls
-			ldap_unbind_ext_s (ld, (IntPtr)null, (IntPtr)null);
+			ldap_unbind_ext_s (ld, IntPtr.Zero, IntPtr.Zero);
 			// FIXME throw something here if ldap_unbind_ext_s returns an error
 		}
 
Index: Test/dslib_linux_test.args
===================================================================
RCS file: /cvs/public/mcs/class/Mono.Directory.LDAP/Test/dslib_linux_test.args,v
retrieving revision 1.1
diff -u -r1.1 dslib_linux_test.args
--- Test/dslib_linux_test.args	16 Sep 2002 21:26:14 -0000	1.1
+++ Test/dslib_linux_test.args	11 Mar 2003 11:01:26 -0000
@@ -1,10 +1,2 @@
---target library
--o dslib_linux_test.dll
---noconfig
--r ../../lib/Mono.Directory.LDAP.dll
--r ../../lib/corlib.dll
--r ../../lib/System.dll
--r ../../../nunit/NUnitCore_mono.dll
 Mono.Directory.LDAP/BindSimpleTest.cs
-Mono.Directory.LDAP/QueryRootDSE.cs
-Mono.Directory.LDAP/AllTests.cs
+Mono.Directory.LDAP/QueryRootDSETest.cs
Index: Test/makefile.gnu
===================================================================
RCS file: /cvs/public/mcs/class/Mono.Directory.LDAP/Test/makefile.gnu,v
retrieving revision 1.1
diff -u -r1.1 makefile.gnu
--- Test/makefile.gnu	16 Sep 2002 21:26:14 -0000	1.1
+++ Test/makefile.gnu	11 Mar 2003 11:01:26 -0000
@@ -3,21 +3,26 @@
 LIBRARY = dslib_linux_test.dll
 
 LIB_LIST = dslib_linux_test.args
-LIB_FLAGS = -r ../../lib/Mono.Directory.LDAP.dll -r ../../lib/corlib.dll -r ../../lib/System.dll \
-	    -r $(topdir)/nunit/src/NUnitCore/NUnitCore_mono.dll
+LIB_FLAGS =     \
+                -r $(topdir)/class/lib/corlib.dll \
+                -r $(topdir)/class/lib/System.dll \
+                -r $(topdir)/class/lib/Mono.Directory.LDAP.dll \
+                -r $(topdir)/nunit20/NUnit.Framework.dll
+
+ifdef SUBDIR
+USE_SOURCE_RULES=1
+SOURCES_INCLUDE=./$(SUBDIR)/*.cs
+SOURCES_EXCLUDE=_DUMMY_
+endif
 
-include ../../library.make
+include $(topdir)/class/library.make
 
-MCS_FLAGS = --target library --noconfig
-
-TEST_SUITE_PREFIX = MonoTests.Directory.LDAP.
-TEST_SUITE = AllTests
-NUNITCONSOLE=$(topdir)/nunit/src/NUnitConsole/NUnitConsole_mono.exe 
-NUNIT_MONO_PATH=$(topdir)/nunit/src/NUnitCore:.
+NUNITCONSOLE=$(topdir)/nunit20/nunit-console.exe
+MONO_PATH = $(topdir)/nunit20:.
 
 test: $(LIBRARY) run_test
 
 .PHONY: run_test
 
 run_test:
-	MONO_PATH=$(NUNIT_MONO_PATH) mono $(NUNITCONSOLE) $(TEST_SUITE_PREFIX)$(TEST_SUITE),dslib_linux_test.dll
+        -MONO_PATH=$(MONO_PATH) mono --debug $(NUNITCONSOLE) $(LIBRARY)
Index: Test/Mono.Directory.LDAP/BindSimpleTest.cs
===================================================================
RCS file: /cvs/public/mcs/class/Mono.Directory.LDAP/Test/Mono.Directory.LDAP/BindSimpleTest.cs,v
retrieving revision 1.1
diff -u -r1.1 BindSimpleTest.cs
--- Test/Mono.Directory.LDAP/BindSimpleTest.cs	16 Sep 2002 21:26:14 -0000	1.1
+++ Test/Mono.Directory.LDAP/BindSimpleTest.cs	11 Mar 2003 11:01:26 -0000
@@ -1,3 +1,4 @@
+// BindSimpleTest.cs 
 
 using NUnit.Framework;
 using System;
@@ -5,26 +6,18 @@
 
 namespace MonoTests.Directory.LDAP
 {
-	public class BindSimpleTest : TestCase {
-		public BindSimpleTest () :
-			base ("[MonoTests.Directory.LDAP.BindSimpleTest]'") {}
+	[TestFixture]
+	public class BindSimpleTest {
 
-		public BindSimpleTest (string name) :
-			base (name) {}
+		[SetUp]
+		public void GetReady () {}
 
-		protected override void SetUp () {}
+		[TearDown]
+		public void Clear () {}
 
-		protected override void TearDown () {}
-
-		public static ITest Suite
+		[Test]
+		public void Stuff() 
 		{
-			get {
-				return new TestSuite (typeof (BindSimpleTest));
-			}
-		}
-		
-
-		public void TestStuff() {
 			string myLDAPPath = "ldap://ldap.toshok.org";
 			string username = "cn=Manager,dc=toshok,dc=org", passwd = "evotest";
 			try {
-------------- next part --------------
// QueryRootDSETest.cs

using NUnit.Framework;
using System;
using Mono.Directory.LDAP;

namespace MonoTests.Directory.LDAP
{
	[TestFixture]
	public class QueryRootDSETest {

		[SetUp]
		public void GetReady () {}

		[TearDown]
		public void Clear () {}

		[Test]
		public void Stuff() 
		{
			string myLDAPPath = "ldap://ldap.toshok.org";
			try {
				LDAP ld = new LDAP (myLDAPPath);
				LDAPMessage res, entry;
				string[] attrs = { "+", null };

				/* don't bind, we do this anonymously */

				ld.Search ("" /* root dse */,
					   SearchScope.Base,
					   "(objectclass=*)",
					   attrs, false,
					   TimeSpan.FromSeconds(10), 0 /* no size limit */,
					   out res);

				if (res == null) {
				  Console.WriteLine ("the search failed");
				}

				Console.WriteLine ("There are {0} entries", res.CountEntries());

				entry = res.FirstEntry();
				if (entry == null)
				  Console.WriteLine ("null returned from res.FirstEntry");

				string[] extensions = entry.GetValues ("supportedExtension");

				if (extensions != null) {
				  foreach( String e in extensions )
				    Console.WriteLine ("Supported Extension: {0}\n", e);
				}
				else {
					Console.WriteLine ("null returned from entry.GetValues\n");
				}
			}
			catch(Exception e) {
				Console.WriteLine("The '" + myLDAPPath + "' path not found.");
				Console.WriteLine("Exception : " + e.Message);
				Console.WriteLine(e.StackTrace);
			}
		}
	}
}


More information about the Mono-devel-list mailing list