You can't access foo and Rhino.Mocks won't help you since it needs to
be in control of creating the CustomerClass2 if you want it to
track/stub virtual method calls.  Since you have the creation
hard-coded, there's no easy way to test the code as it is currently
written.

One alternative might be to create a factory to control creation of
CustomClass2.  During production, the factory would just do as you
currently do -- new up a new CustomClass2.  During testing, you could
provide a mock factory which, in turn, could be set up to return a
mock CustomClass2.  If "Start" is a virtual method on CustomClass2,
then Rhino.Mocks can intercept and track if it was called.

---
Patrick Steele
http://weblogs.asp.net/psteele


On Tue, Jun 19, 2012 at 1:12 PM, Adam <[email protected]> wrote:
> I'm new to rhino mocks, so please bear with me, but this is my method:
>
>  public void Foo(CustomClass1 Param1)
>         {
>             CustomClass2 foo = new CustomClass2(Private void method, Param1)
>                 { Property = _property };
>             foo.Start();
>         }
>
> And I want to assert that foo.Start() was called...
>
> [TestMethod()]
>         public void FooTest()
>         {
>             var target =
> MockRepository.GenerateMock<CustomClass_Accessor>();
>             var Param1 = MockRepository.GenerateMock<CustomClass1>();
>             target.Foo( Param1 );
>         }
>
> That's where I am now, but I don't see how to access the constructed foo or
> its methods.
>
> Thanks a lot!
>
> Adam
>
> --
> 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/-/vlc9lvATtyoJ.
> 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