I believe it's because he doesn't have access to ClassA and ClassB, he only
has them in binary form.

2009/11/13 Stefan Steinegger <[email protected]>

>
> Why does ClassA not implement IClassA, and ClassB not IClassB??
>
> You can't mock IClassB when it is referenced by its concrete type. Why
> is the reference not of type IClassB?
>
> On 12 Nov., 09:45, Fredrik H <[email protected]> wrote:
> > Hi!
> > I'm currently struggeling with a mocking problem that perhaps someone
> > can help me find a solution to.
> >
> > I'm not able to describe the problem in word so i need to write a
> > little code.
> > I have to classes i need to mock that i cannot change. I only have
> > them in binary form. ClassA and ClassB
> >
> > public ClassA
> > {
> >    public ClassB classb
> >   {
> >   get
> >       {
> >          return _classb;
> >       }
> >    set
> >       {
> >          _classb = value;
> >       }}
> >
> > ClassB's implementation is unimportant.
> >
> > Since they're not sealed i can create a new class that inherit the
> > class and implement an interface that specifies the signature of the
> > class and then mock that interface.
> >
> > public interface IClassA
> > {
> >  public ClassB { get; set;}
> >
> > }
> >
> > public class MyClassA : ClassA, IClassA
> > {
> >
> > }
> >
> > public interface IClassB
> > {
> > //any properties
> >
> > }
> >
> > public class MyClassB : ClassB, IClassB
> > {
> >
> > }
> >
> > the problem is that i need to insert a mock in ClassA's classb
> > property;
> > _classa.classb = mock.StrictMock(IClassB);
> > This won't work since the property is of type ClassB, i cannot insert
> > a IClassB into it.
> > I've tried changing the interface to IClassB but this causes other
> > problems.
> >
> > Has anyone solved a similar problem?
> >
> > Best Regards
> > Fredrik H
> >
>

--~--~---------~--~----~------------~-------~--~----~
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