This is a migrated thread and some comments may be shown as answers.

NUnit test fails when using Kendo.Mvc

4 Answers 175 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Ljubomir
Top achievements
Rank 1
Ljubomir asked on 28 Mar 2014, 04:15 PM
Hello,

i am facing strange issue with my unit tests and Kendo.Mvc.

My test consist of invoking of controller action which is basically a handler for Grid control:

public virtual ActionResult Get([DataSourceRequest]DataSourceRequest request)
{
    var products = _userService.GetProducts();
    result = products.ToDataSourceResult(request);
 
    return Json(result);
}

The error i am getting from the NUnit console is following:

System.IO.FileNotFoundException : Could not load file or assembly 'System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

All of my projects are targeted against .NET 4.5.1.
Web project is targeting Asp.NET Mvc 5.1 version, which means iam using System.Web.Mvc version 5.1.0.0.
Kendo.Mvc is from the latest release - 2014.1.318.545


To make things even more complicated, when i run the test in isolation (only this one) it passes flawlessly.
But when i try to invoke it using NUnit console it fails throwing the above error.

Any hint is appreciated,
Ljubomir

4 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 01 Apr 2014, 01:29 PM
Hello Ljubomir,

I am not sure what might be behind this, is the problem caused by the types that are coming from the Kendo namespace? I am not sure if the issue is caused by the Kendo framework, I would suggest to search the net for similar questions:

http://stackoverflow.com/questions/399972/nunit-could-not-load-file-or-assemby-mytestproject
http://stackoverflow.com/questions/9241221/nunit-filenotfoundexception-system-configuration


Kind Regards,
Petur Subev
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
Ljubomir
Top achievements
Rank 1
answered on 02 Apr 2014, 09:47 AM
Hi Petur,

thanks for the feedback. Unfortunately, provided references on SO does not match my scenario.

When i remove the Kendo.Mvc method from the action the problem disappears:

result = products.ToList();

What is also strange is that i don't have reference to System.Web.Mvc 5.0.0.0 anywhere in the solution. And when i try to see the referenced libraries Kendo.Mvc is using (using reflector), i am not able to see version information for System.Web.Mvc.
0
Petur Subev
Telerik team
answered on 02 Apr 2014, 02:51 PM
Hello again Ljubomir,

Since Kendo.Mmc.dll refers to System.Web.Mvc.dll 5.0.0.0 you will need to create a binding redirect to System.Web.Mvc.dll 5.1.0.0. Could you try and see if such binding redirect resolves the case?

web.config
<?xml version="1.0" encoding="utf-8"?>
 
<configuration>
  ...
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-5.0.0.0" newVersion="5.1.0.0" />
      </dependentAssembly>
      

http://stackoverflow.com/questions/22001797/when-i-update-asp-net-mvc-from-5-0-to-5-1-do-i-need-to-update-the-bindingredire

Regards,
Petur Subev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Ljubomir
Top achievements
Rank 1
answered on 02 Apr 2014, 04:10 PM
Thanks for the follow-up Petur,

Although this didn't solved the problem, it led me to final solution of the problem.

As it turned out, nunit-console is running all tests under one App.Domain - created with the first test run.
In my case, this was a non-mvc uinit test library that didn't contained reference to System.Web.Mvc and that is why the tests were failing.
Changing the domain usage parameter in nunit-console to Multiple solved the problem.

>nunit-console.exe test-suite.nunit /domain=Multiple


More info as well as fix for ReSharper test runner can be found here: http://stackoverflow.com/questions/17877471/running-nunit-through-resharper-8-tests-fail-when-crossing-between-projects-due


Kind Regards,
Ljubomir
Tags
General Discussions
Asked by
Ljubomir
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Ljubomir
Top achievements
Rank 1
Share this question
or