4

A heap of our unit tests are failing under Mono on OS X with the following error:

System.TypeLoadException : Could not load type 'System.Func``2' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

On of the unit tests in question:

[Test]
public void CanAuthenticateValidUser()
{
    const string testUsername = "jappleseed";

    var repo = new Mock<IUserRepository>();
    repo.Setup(x => x.GetByUsername(testUsername)).Returns(GetTestUser());

    var authenticator = new Authenticator(repo.Object);
    var result = authenticator.Authenticate(testUsername, "test");

    Assert.That(result, Is.True);
}

Running against Mono 2.8, with MonoDevelop 2.4.

Anyone got any suggestions to get around this?

Edit:

Should point out this error is coming from the inbuilt "Run Tests" command in the "Unit Tests" pad in MonoDevelop.

Edit 2:

Forcing the runtime as per jpobst suggestion runs in the console. I guess the question has become how does one get MonoDevelop to exhibit run tests under a specific framework?

shimms:Debug shimms$ mono ~/Development/nunit/bin/net-2.0/nunit-console.exe Convergence.Core.Services.Tests.dll

Throws the same exceptions, however:

shimms:Debug shimms$ mono --runtime=v4.0.30319 ~/Development/nunit/bin/net-2.0/nunit-console.exe Convergence.Core.Services.Tests.dll

All tests pass

Michael Shimmins
  • 19,961
  • 7
  • 57
  • 90

1 Answers1

6

There isn't an assembly called "mscorelib", it's "mscorlib". Is that a typo? Or a broken reference?


Second try:

Are you sure your tests were compiled against 4.0 (dmcs)?

You can also try overriding the runtime with:

mono --runtime=v4.0.30319 mytests.exe

jpobst
  • 9,982
  • 1
  • 29
  • 33