C# – Nunit .net vs mono

cmononunit

I have written a simple test application using asp.net mvc with C#. The application uses MySQL
by using dblinq to generate linq to MySQL files and the application is working both in windows and linux.

I have now started to use NUnit to test my code, mostly since I need to test if the code working under
windows also will work in linux.
My NUnit tests runs well under Windows but not under Linux.

This my Windows environment:

NUnit version 2.5.1.9189 Copyright (C)
2002-2009 Charlie Poole. Copyright (C)
2002-2004 James W. Newkirk, Michael C.
Copyright (C) 2000-2002 Philip Craig.
All Rights Reserved.

Runtime Environment – OS Version:
Microsoft Windows NT 5.1.2600 Service
CLR Version: 2.0.50727.3053 ( Net
2.0.50727.3053 )

This my Linux environment with the error (Library is my application name):

NUnit version 2.4.8 Copyright (C)
2002-2007 Charlie Poole. Copyright (C)
2002-2004 James W. Newkirk, Michael C.
Two, Alexei A. Vorontsov. Copyright
(C) 2000-2002 Philip Craig. All Rights
Reserved.

Runtime Environment – OS Version:
Unix 2.6.24.24 CLR Version:
1.1.4322.2032 ( Mono 2.4.2.2 )

** (/usr/local/lib/mono/1.0/nunit-console.exe:4888):
WARNING **: The class
System.ComponentModel.INotifyPropertyChanged
could not be loaded, used in System,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089 File
or assembly name Library.Tests,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null, or one of its
dependencies, was not found.

I can't figure out what I am doing wrong. Do you have any tips? It seems like I need to include System.ComponentModel.INotifyPropertyChanged, I have searched
the Internet to see if it is implemented in mono but I can't find any information.
Thank you

Best Answer

Somehow you've started the 1.1 CLR - note "CLR Version: 1.1.4322.2032 ( Mono 2.4.2.2 )"

I'm not sure how you've done that, but I'm pretty sure that's the problem... How exactly are you running NUnit? I suspect that the problem is you're using a version of NUnit compiled against .NET 1.1, so Mono decides to load its own CLR v1.1. Assuming you're explicitly calling the mono binary, try specifying the --runtime argument, like this:

mono --runtime=2.0.50727 (whatever you previously had here)

EDIT: To find out which runtime version you've got, try this Test.cs file:

using System;

class Test
{
    static void Main()
    {
        Console.WriteLine(Environment.Version);
    }
}

Then compile and run it:

$ gmcs Test.cs
$ mono Test.exe
2.0.50727.1433

What version do you get out at the bottom?

Related Topic