I have this type:
[RequiresAuthentication]
public class MobileRunReportHandler : IMobileRunReportHandler
{
public void Post(MobileRunReport report)
{
...
}
}
I am mocking it like so:
var handler = MockRepository.GenerateStub<IMobileRunReportHandler>();
handler.Stub(x => x.Post(mobileRunReport));
The problem is that the produced mock is not attributed with the RequiresAuthentication attribute. I want the mocked type to be attributed with the RequiresAuthentication
attribute, because the code that I am testing makes use of this
attribute. I would like to know how can I change my mocking code to
instruct the mocking framework to attribute the produced mock
accordingly.
Note, that I cannot use IReflectionService, because I have no control over the code which expects the attribute, so the mock must be attributed for real.
Thanks.
--
You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rhinomocks/-/oY4c0VAIRaIJ.
To post to this group, send email to rhino...@googlegroups.com.
To unsubscribe from this group, send email to rhinomocks+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rhinomocks?hl=en.
If you use moq instead you can simply mock the concrete class with the attribute already applied:
var m = new Mock<MobileRunReportHandler>();
Regards,
Felix
To clarify, my original post works if you use moq. You don't necessarily need the call base depending on your requirements. Moq allows mocking of non virtual members just there same as virtual ones.
Regards
---
Patrick Steele
http://weblogs.asp.net/psteele
I stand corrected! I thought I had used that behavior in the past.
Regards