You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Rhino.Mocks
Hi,
I was mocking a concrete class and its methods.I found tha I have to
declare those methods as virtual.Why so? Is it because rhinomocks
creates a class at runtime which it inherits from the concrete class?
regards
vishy
isaiah perumalla
unread,
Jan 16, 2008, 11:57:11 AM1/16/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Rhino...@googlegroups.com
yep that right, the mocking framework creates a mock implementation for you conrecte class by subclassing it(your concrete class you want to mock must not be sealed) and overrides the method you want to call. this cant be done if you methods are not virtual, since all methods in C# are not virtual by default.
isaiah
-- Isaiah Perumalla
isaiah perumalla
unread,
Jan 16, 2008, 12:29:01 PM1/16/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Rhino...@googlegroups.com
sorry the framework doesnt actually subclass the concrete class, what it does is, it uses reflection to create a DynamicProxy at runtime which can only intercept virtual method calls.
-- Isaiah Perumalla
Ayende Rahien
unread,
Jan 16, 2008, 12:39:25 PM1/16/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Rhino...@googlegroups.com
Dynamic Proxy subclass the class at runtime, you were right the first time.
isaiah perumalla
unread,
Jan 16, 2008, 12:42:10 PM1/16/08
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message