Tuesday, February 23, 2010

Rhino.Mocks -Unit Testing


Rhino.Mocks is an attempt to create easier way to build and use mock objects and allow better refactoring support from the current tools. It's a hybrid approach between the pure Record/Replay of EasyMock.Net's model and NMock's expectation based model. Rhino.Mocks originated from EasyMock.Net and attempt to improve on their model to create easy to use and power mocking framework. It's free for use and modification for open source and commercial software.
Licensing: Rhino Mocks is Free Software which is released under the BSD license.


What does Rhino Mocks offers?

Explicit record & replay model for expectations.
Natural Arrange, Act, Assert syntax
Support for .Net 2.0 and .Net 3.5
Working with strongly typed mocks.
Expectations based on:
Arguments matching
Constraints matching
Custom callback to verify the expected arguments using your own code
Setting actions on methods, return specific value, or throw an exception.
Some things to be aware of:
Ø You cannot create a mock object from a sealed class.
Ø You cannot intercept calls to non-virtual methods.

Reference:

-------------------------------------------------------------------------------------------------http://www.ayende.com/projects/rhino-mocks/api/files/MocksRepositoryGenerics-cs.html http://www.ayende.com/projects/rhino-mocks/api/files/MockRepository-cs.html [Mock Repository]
http://www.codeproject.com/KB/dotnet/Rhino_Mocks_Version_20.aspx
http://www.ayende.com/projects/rhino-mocks/api/index/Functions.html [Mock Functions]
http://www.ayende.com/wiki/AllPages.aspx [Mock Syntax]
http://codevanced.net/page/Talks-Mock-n-Roll.aspx [Why we need mock]
http://en.wikipedia.org/wiki/Mock_object [Mock object]http://highoncoding.com/Articles/447_Introduction_to_Mocking.aspxhttp://highoncoding.com/Articles/449_A_Look_at_CreateMock__DynamicMock_and_PartialMock_Methods_in_RhinoMocks.aspx
http://groups.google.com/group/rhinomocks/browse_thread/thread/dde2314300e0ef09/f5a9c4d7d28a0168?show_docid=f5a9c4d7d28a0168 [Sample Code]


http://www.superexpert.com/blog/archive/2008/03/23/tdd-introduction-to-rhino-mocks.aspx

Dynamic Vs StrickMock

http://www.thycotic.com/strictmock-vs-dynamicmock-what-are-you-testing-here-anyway [Event Handlers for Mocks]http://groups.google.com/group/RhinoMocks/browse_thread/thread/b4718f2b3a000943

No comments: