That's what I'd do, but I'm not master. :)

On Wed, Jun 17, 2009 at 10:43 PM, [email protected] <[email protected]
> wrote:

>
> By "extracting an interface from the third party class directly" do
> you mean creating a wrapper class which implements an interface which
> defines the methods I'm interested in?
>
> On Jun 18, 11:34 am, Chris Missal <[email protected]> wrote:
> > I think it would be easier to mock if you extracted an interface from the
> > third party class directly, rather than another class. This way, you
> don't
> > have to worry about the constructor.
> >
> > On Wed, Jun 17, 2009 at 10:29 PM, [email protected] <
> [email protected]
> >
> >
> >
> >
> >
> > > wrote:
> >
> > > Yep, I'm not mocking the SUT (although I do admit that I got confused
> > > about this at first too).
> >
> > > Basically, I am wrapping a 3rd party class in my own class so that I
> > > can mock it (since that 3rd party class doesn't implement an interface
> > > which defines the methods I am interested in, neither are the methods
> > > I'm interested in defined as virtual). I'm trying to do it by
> > > implementing the wrapper class as a class with virtual methods (rather
> > > then a normal class without overridable methods but which implements
> > > an interface which defines those methods) - it didn't make sense to me
> > > to have the interface simply for the sake of having it...
> >
> > > On Jun 18, 11:22 am, Chris Missal <[email protected]> wrote:
> > > > Since it's a mock, the dependencies shouldn't matter since you'll be
> > > > artificially handling the functionality of the mocked object.
> >
> > > > Be sure that the object you're mocking isn't the class under test,
> > > usually
> > > > you'll mock the dependencies or the classes that the class under test
> (or
> > > > system under test (SUT)) interacts with, are mocked.
> >
> > > > Make sense? This was a bit confusing for me at first.
> >
> > > > On Wed, Jun 17, 2009 at 10:14 PM, [email protected] <
> > > [email protected]
> >
> > > > > wrote:
> >
> > > > > Sure does.
> >
> > > > > In fact, it doesn't stop me from doing
> >
> > > > > SomeClass c = MockRepository.CreateMock<SomeClass>(null, null);
> >
> > > > > either (the dependencies of SomeClass shouldn't matter in this case
> > > > > since it is just a mock).
> >
> > > > > So this problem is not stopping me from using RhinoMocks to mock
> the
> > > > > class, it's just that this behaviour appears to contradict the wiki
> > > > > and as this is my first time mocking a class (I have always mocked
> > > > > interfaces before), I was worried that I was doing something
> wrong...
> >
> > > > > On Jun 18, 11:11 am, Chris Missal <[email protected]> wrote:
> > > > > > Does it work when you try:
> >
> > > > > > SomeClass c = MockRepository.CreateMock<SomeClass>(a, b);
> >
> > > > > > On Wed, Jun 17, 2009 at 9:39 PM, [email protected]
> > > > > > <[email protected]>wrote:
> >
> > > > > > > Hi,
> >
> > > > > > > I'm trying to mock a class that doesn't have a default
> constructor
> > > > > > > (i.e. it has been 'overidden' by a custom constructor which is
> > > > > > > parameterized) which - according to the wiki (
> > >http://ayende.com/wiki/
> > > > > > > Rhino%20Mocks%20Mocking%20classes.ashx) - should be possible.
> There
> > > > > > > isn't anything particularly special about what I'm trying to
> do,
> > > > > > > simply something like the following:
> >
> > > > > > > public class SomeClass
> > > > > > > {
> > > > > > >        public SomeClass(A a, B b)
> > > > > > >        { ... }
> >
> > > > > > >        virtual public string SomeMethod()
> > > > > > >        { ... }
> > > > > > > }
> >
> > > > > > > [Test]
> > > > > > > public void SomeTest()
> > > > > > > {
> > > > > > >        SomeClass c = MockRepository.CreateMock<SomeClass>();
> > > > > > >        ...
> > > > > > > }
> >
> > > > > > > NUnit reports the following error:
> >
> > > > > > > System.MissingMethodException : Can't find a constructor with
> > > matching
> > > > > > > arguments
> > > > > > >  ----> System.MissingMethodException : Constructor on type
> > > > > > > 'SomeClass207ade2ffbbc4e7cba459d96ac172bb9' not found.
> >
> > > > > > > cheers!
> >
> > > > > > --
> > > > > > Chris Missalhttp://chrismissal.lostechies.com/
> >
> > > > --
> > > > Chris Missalhttp://chrismissal.lostechies.com/
> >
> > --
> > Chris Missalhttp://chrismissal.lostechies.com/
> >
>


-- 
Chris Missal
http://chrismissal.lostechies.com/

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