MOCKING WITH MOQ
By Anney
2

WHAT
• Moq (pronounced "Mock-you" or just "Mock") is the only mocking library
for .NET developed from scratch to take f...
3

WHY
• the object supplies non-deterministic results (e.g., the current time or the
current temperature);
• has states t...
4

HOW
• Step
• Create mock instance with
• Setting mock
• Using mock object

2013/12/8
5

EXAMPLE – MOCK HTTPCONTEXT

2013/12/8
6

TEST EXAMPLE

2013/12/8
7

SETUP METHODS

2013/12/8
8

REFERENCES
• http://code.google.com/p/moq/
• http://code.google.com/p/moq/wiki/QuickStart
• http://msdn.microsoft.com/z...
2013/12/8

9

~ THE END ~
Upcoming SlideShare
Loading in...5
×

20131206 moq mock_by_anney

128

Published on

Published in: Technology, Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
128
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

20131206 moq mock_by_anney

  1. 1. MOCKING WITH MOQ By Anney
  2. 2. 2 WHAT • Moq (pronounced "Mock-you" or just "Mock") is the only mocking library for .NET developed from scratch to take full advantage of .NET 3.5 (i.e. Linq expression trees) and C# 3.0 features (i.e. lambda expressions) that make it the most productive, type-safe and refactoring-friendly mocking library available. 2013/12/8
  3. 3. 3 WHY • the object supplies non-deterministic results (e.g., the current time or the current temperature); • has states that are not easy to create or reproduce (e.g., a network error); • is slow (e.g., a complete database, which would have to be initialized before the test); • does not yet exist or may change behavior; • would have to include information and methods exclusively for testing purposes (and not for its actual task). 2013/12/8
  4. 4. 4 HOW • Step • Create mock instance with • Setting mock • Using mock object 2013/12/8
  5. 5. 5 EXAMPLE – MOCK HTTPCONTEXT 2013/12/8
  6. 6. 6 TEST EXAMPLE 2013/12/8
  7. 7. 7 SETUP METHODS 2013/12/8
  8. 8. 8 REFERENCES • http://code.google.com/p/moq/ • http://code.google.com/p/moq/wiki/QuickStart • http://msdn.microsoft.com/zhtw/library/system.web.httpcontextbase(v=vs.110).aspx • http://msdn.microsoft.com/zhtw/library/system.web.httpcontextwrapper(v=vs.110).aspx • http://blog.miniasp.com/post/2010/09/16/ASPNET-MVC-Unit-Testing-Part-03Using-Mock-moq.aspx • http://www.agile-code.com/blog/mocking-with-moq/ 2013/12/8
  9. 9. 2013/12/8 9 ~ THE END ~
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×