chevron-thin-right chevron-thin-left brand cancel-circle search youtube-icon google-plus-icon linkedin-icon facebook-icon twitter-icon toolbox download check linkedin phone twitter-old google-plus facebook profile-male chat calendar profile-male
0 votes
Try to run this test
using MbUnit.Framework;
using TypeMock;

namespace TypeMockBug
{
   [TestFixture]
   public class MatrixTest
   {
      [TestFixtureSetUp]
      public void TestFixtureSetUp()
      {
         MockManager.Init();
      }

      [TearDown]
      public void TearDown()
      {
         MockManager.Verify();
      }

      [Test]
      public void FirstTest()
      {
         ISomething mockSomething = (ISomething) RecorderManager.CreateMockedObject(typeof(ISomething));
      }
   }

   public interface ISomething
   {
      double[,] GetMatrix();
   }
}



this is the exception
MatrixTest.FirstTest.TearDown
TestCase 'MatrixTest.FirstTest.TearDown'
failed: Method GetMatrix in type MockISomething from assembly DynamicMockAssembly, Version=0.0.0.0 does not have an implementation.
   System.TypeLoadException
   Message: Method GetMatrix in type MockISomething from assembly DynamicMockAssembly, Version=0.0.0.0 does not have an implementation.
   Source: mscorlib
   StackTrace:
   at System.Reflection.Emit.TypeBuilder.TermCreateClass(TypeToken handle, Module module)
   at System.Reflection.Emit.TypeBuilder.CreateType()
   at u.a(Type A_0, Object[] A_1)
   at TypeMock.MockManager.MockObject(Type type, Constructor mockConstructors, Object[] args)
   at TypeMock.MockManager.MockObject(Type type, Object[] args)
   at TypeMock.RecorderManager.CreateMockedObject(Type typeToMock)
   c:sviluppo	ypemockbug	ypemockbugmatrixtest.cs(25,0): at TypeMockBug.MatrixTest.FirstTest()
asked by acarpe (1.7k points)

2 Answers

0 votes
Hi
You found a bug. Thanks for reporting.
We will fix it and send you the patch.
answered by ohad (35.4k points)
0 votes
This is a known bug, and has to do with a bug in mscorlib, you can find more infomation in this post

The workaround is to mock a concrete implementation of ISomething
public class MockedISomething: ISomething
{...}

[Test]
public void FirstTest()
{
   ISomething mockSomething = 
   (ISomething)RecorderManager.CreateMockedObject(typeof(MockedISomething));
} 
answered by scott (32k points)
...