c# - Testing a repository with MSTest and Moq - .Verify not working -


i looking @ writing unit tests basic execution timer moq. there function called when timer stopped adds timings database , need test insert has been called. have used similar kind of test test inserts via homecontroller being done directly.

// calls addtolog() iterates through list  // adding entries database  _timer.stop();  _repository.verify(x => x.insert(timerobject)); 

the error receiving is:

expected invocation on mock @ least once, never performed: x => x.insert(.splittimer)  performed invocations: itimersrepository.insert(ef.domain.entities.timer) itimersrepository.insert(ef.domain.entities.timersplit) itimersrepository.save() 

the addtolog() method defiantly being called , calling .insert repository. i'm not sure why comes not being called?

any ideas great.

thanks

_timerrepository.verify(x => x.insert(it.isany<timer>())); 

this trick needed. checks see if insert has been triggered type of timer , not specific (since cant object created else where)


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -