While mocking interface using NUnit throws exception of type 'System.IO.FileLoadException'


Currently using NUnit framework 3.12 for writing unit test cases in my .Net project in C#. When I am trying to mock an interface it's gives below error:
'((Moq.Mock)InterfaceName).Object' threw an exception of type 'System.IO.FileLoadException'. And getting below coming an inner exception message after adding watch:

Could not load file or assembly 'Newtonsoft.Json, Version=, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I am unable to mock the interface object, please help what might be the cause of this issue. Below is my packages.config content

<?xml version="1.0" encoding="utf-8"?>
<package id="Castle.Core" version="4.3.1" targetFramework="net461" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" 
 <package id="Microsoft.AspNet.Razor" version="3.2.3" 
  targetFramework="net461" />
 <package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" 
   TargetFramework="net461" />
 <package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" 
  targetFramework="net461" />
 <package id="Microsoft.AspNet.WebP`enter code here`ages" version="3.2.3" 
 targetFramework="net461" />
 <package id="Microsoft.Web.Infrastructure" version="" 
  targetFramework="net461" />
 <package id="Moq" version="4.10.0" targetFramework="net461" />
 <package id="Newtonsoft.Json" version="6.0.4" targetFramework="net461" />
 <package id="NUnit" version="3.12.0" targetFramework="net461" />
 <package id="System.Threading.Tasks.Extensions" version="4.3.0" 
 targetFramework="net461" />
 <package id="System.ValueTuple" version="4.4.0" target`enter code 
 here`Framework="net461" />
asked on Stack Overflow Apr 23, 2020 by user3563556 • edited Apr 23, 2020 by user3563556

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0