Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can any one suggest a step by step example for using moQ framework

Can any one suggest a step by step example for using moQ framework.

any guidelines or thumbrules that has to be followed while mocking objetcs . can be much help.

thanks.

like image 497
vijaysylvester Avatar asked Feb 04 '23 10:02

vijaysylvester


2 Answers

Here's the moq quick-start

Update: To address your comment... A large part of writing testable code involves removing dependencies on classes/resources outside the scope of your control. A very common approach to doing this is by talking to interfaces instead of concrete examples.

It's a little much to describe properly (especially since I just rolled out of bed), so let suggest you pick up a copy of Roy Osherove's 'The Art of Unit Testing'. It's a fairly short book and is filled with good advice and lots of summary information to get you familiar with many of the approaches to unit testing.

like image 153
STW Avatar answered Feb 06 '23 14:02

STW


I only started to use Moq recently and I am not sure how much help this will be but if you can get your hands on Chapter 3 of Pro ASP.NET MVC Framework there is a really good step-by-step example of using moq and NUnit with ASP.NET MVC.

like image 37
Skittles Avatar answered Feb 06 '23 15:02

Skittles