The Rhino Mock Expect () method runs the function of the expected function

I use Rhino Mocks 3.6 in C # and I experience problems when taunting objects instead of interfaces. Can someone explain why the methods are actually called in determining expectations?

   public class MockingBird
   {
      public void TestMethod()
      {
         throw new Exception("Method call!");
      }
   }

...

 [TestMethod]
  public void TestMock()
  {
     var mockedMockingBird = MockRepository.GenerateStrictMock<MockingBird>();
     mockedMockingBird.Expect(x => x.TestMethod());
  }
+4
source share
1 answer

You cannot make fun of methods that are not redefined . When creating a fake instance, Rhino does the following:

  • It generates a dynamic assembly at runtime (the Castle Dynamic Proxy library is used for this )
  • In this assembly, Rhino creates a new type based on the type you want to make fun of
  • /.

virtual/abstract .

, .

+5

All Articles