Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I enforce a void method to return Void from a Stub object?

How can I enforce a stub object in RhinoMocks to return void for a void method on it?

Take this example:

public interface ICar 
{
    string Model {get;set;}
    void Horn();
}

ICar stubCar= MockRepository.GenerateStub<ICar>();
stubCar.Expect(c=>c.Horn()).Return( //now what so that 
                                   // it returns nothing as the meth. returns void ? 
like image 462
pencilCake Avatar asked Oct 11 '11 14:10

pencilCake


1 Answers

The method can't return a value - it's a void method. The CLR won't let it try to return a value. You don't need to test for this.

You only need the Expect call.

like image 69
Jon Skeet Avatar answered Sep 21 '22 21:09

Jon Skeet