Perhaps this is because you are passing null , but It.IsAny<Object>() expects any object except null ? What happens if you do the following:
var actual = mock.Object.Convert(value, new object(), typeof(object), CultureInfo.CurrentCulture);
This is just a blow in the dark from me, I am more familiar with Rhino.Mocks.
My second guess:
By looking at Moq.chm, which comes with a download,
You are using the Setup(Expression<Action<T>>) method Setup(Expression<Action<T>>) , which "Indicates the setting for the laugh type to invoke the void method."
You want to use the te Setup<TResult>(Expression<Func<T,TResult>>) method, which "Indicates the setting for the laughing type to invoke the return method."
So you can try:
mock.Setup<Int32>( conv => { conv.Convert( It.IsAny<Object>(), It.IsAny<Type>(), It.IsAny<Object>(), It.IsAny<CultureInfo>()); return num + 5; });
Grokodile Oct 10 '11 at 15:05 2011-10-10 15:05
source share