c# - new HttpConfiguration(); fails with Nunit but not MsTests -
i trying make test project using nunit test webapi 1 routes. problem exception:
an exception of type 'system.io.filenotfoundexception' occurred in system.net.http.formatting.dll not handled in user code
additional information: not load file or assembly 'newtonsoft.json, version=4.5.0.0, culture=neutral, publickeytoken=30ad4fe6b2a6aeed' or 1 of dependencies. system cannot find file specified.
i have tryed run code mstests (a new testproject) , exception not there.
using system; using microsoft.visualstudio.testtools.unittesting; using system.web.http; using nunit.framework; namespace unittestproject1 { [testfixture] [testclass] public class unittest1 { [test] [testmethod] public void testmethod1() { var config = new httpconfiguration(); } } } so on exemple can run both mstest , nunit. mstest works fine nunit doesn't. knows why ? tryed gallio + mbunit , doesn't work.
more info: frameworktarget: .net 4.0 system.web.http version 4.0.0
just add reference newtonsoft.json , in app.config/web.config add these lines:
<runtime> <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentassembly> <assemblyidentity name="newtonsoft.json" publickeytoken="30ad4fe6b2a6aeed" culture="neutral"/> <bindingredirect oldversion="0.0.0.0-6.0.0.0" newversion="6.0.0.0"/> </dependentassembly> </assemblybinding> </runtime> it seems mstests these steps not required nunit are. same modification apply if try create object plain consoleapplication.
Comments
Post a Comment