asp.net mvc - Unit Tests - Referencing 3.0.0.0 MVC, version actually 4.0.0.0 -
i've googled, answers haven't been helpful me personally.
i testing sendemail using unit tests (nunit)
// arrange var mockdbcontext = new mock<dbcontext>(); iservice service = new service(mockdbcontext.object); // act var result = service.sendemail(string.empty,1,1); //assert assert.that(result, is.not.null); assert.that(result, is.instanceof<bool>()); assert.areequal(result, false); public bool sendemail(string emailaddress, int mid, int deadline) { try { dynamic email = new email("circulationemail"); email.to = emailaddress; email.mid = mid; email.deadline = deadline; email.send(); return true; } catch (exception ex) { elmah.errorsignal.fromcurrentcontext().raise(ex); return false; } }
sendemail uses postal.
i following error when run test. when debug throws error before hitting first debug point within sendemail.
system.io.fileloadexception : not load file or assembly 'system.web.mvc, version=3.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35' or 1 of dependencies. located assembly's manifest definition not match assembly reference. (exception hresult: 0x80131040)
i added below app.config , searched through code see if ever references 3.0.0.0, doesn't.
<runtime> <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentassembly> <assemblyidentity name="system.web.mvc" publickeytoken="31bf3856ad364e35" culture="neutral" /> <bindingredirect oldversion="0.0.0.0-4.0.0.0" newversion="4.0.0.0" /> </dependentassembly> </assemblybinding> </runtime>
i wondering if maybe error message being masked (somehow) mvc wrong version one?
thanks in advance :-)
clare
a couple of options:
there few ways find out assembly loaded from. best 1 use sysinternal's processmonitor
see file loading before error happens.
also try check in project if assembly reference configured "exact match".in project "references" folder select reference, go "properties" , change "specific version" false.
Comments
Post a Comment