I have written a method as suggested in https://stackoverflow.com/a/79903/976896. In short its a method that accepts all kind of Enums as argument and does some basic checking.
public void SaveIntValueFromEnum<T>(T value) where T : struct, IConvertible
{
if (!typeof(T).IsEnum)
{
throw new ArgumentException("T must be an enumerated type");
}
this.intValue = Convert.ToInt32(value);
}
Now I want to write a test for this, that validates that when a non Enum type is feed to it, an exception is thrown. I wanted to generate a dummy object as follow with RhinoMocks.
var mock = MockRepository.GenerateMock<IConvertible>();
But the method doesn't accepts the nullable type.
Is there a way to mock structs/non-nullable instances with RhinoMocks?
Edit: Updated code listing