0

I have this situation:

A method that expects a Type as one of its parameter; This Type must be a Type that implements an Interface in the project; I need to write tests for this method; I'm using NMock2;

Is there any way to get a Type from NMock2 so I can use it as a parameter of this method instead of create an implementation of this interface?

Thanks!

Bruno
  • 4,337
  • 12
  • 42
  • 55

1 Answers1

0

I prefer using Moq, but from what I can see, you should be able to retrieve a fake and use it like follows:

var mocks = new Mockery();
var someFakeType = mocks.NewMock<ISomeType>();

// do whatever you need to setup this fake
// such as setting expectations, stubing properties or methods, etc

var someObject = new SomeObject();
someObject.MethodUnderTest(someFakeType);
Matt
  • 14,353
  • 5
  • 53
  • 65