If you use moq instead you can simply mock the concrete class with the
attribute already applied:

var m = new Mock<MobileRunReportHandler>();

Regards,
Felix
On 5 Oct 2011 10:53, "mark Kharitonov" <[email protected]> wrote:
>
>
> 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.
> P.S.
> I have original posted this question on SO -
>
http://stackoverflow.com/questions/7588597/is-it-possible-to-mock-a-type-with-an-attribute-using-rhino-mocks,

> but no one has provided any answer...
>
> --
> 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 [email protected].
> To unsubscribe from this group, send email to
[email protected].
> For more options, visit this group at
http://groups.google.com/group/rhinomocks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rhinomocks?hl=en.

Reply via email to