Can u create a mock on ClassB and set it? Right now the mock is
created on the interface not the class.

On 11/12/09, 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
>
>
>
>
> >
>

-- 
Sent from my mobile device

Tim Barcz
Microsoft C# MVP
Microsoft ASPInsider
http://timbarcz.devlicio.us
http://www.twitter.com/timbarcz

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