nunit - NullRefernceException when calling Setup -


i'm trying simple setup on mocked object, nullrefernceexception coming setup line:

enter image description here

what mistake doing here?

your setup incorrect because confusing moq .tostring() in it.isany<string>().tostring().

because of moq cannot generate correct matcher , throws exception.

it easy fix this, remove .tostring():

[test] public void test() {     mockdatabase = new mock<idatabase>();     dataset ds = new dataset();     mockdatabase.setup(m => m.dbquery(it.isany<string>())).returns(ds);     var sut = new businessclass(mockdatabase.object);     sut.somemethod(); } 

Comments

Popular posts from this blog

json - Zend error Connection -

javascript - Trigger mouseenter when an animated element touches mouse -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -