I try to create a mock for System.Enum. That works for all public static methods of the System.Enum class (i.e. Enum.GetValues). But I have no idea how to set up the mock for the ToString() method of the Enum object.
(all C# .NET)
publicstaticvoidTestThis(ListControl ctrl, Type enumType, Enum enumItem= null)
DropDownList ddlTestList = new DropDownList();
TestThis(ddlTestList, typeof(TestEnum), TestEnum.Empty)
1 Answer, 1 is accepted
answered on 24 Jul 2013, 08:25 AM
It's simply impossible to arrange the instance methods of System.ValueType and System.Enum. Like the exception says, it's a limitation of the CLR.
As a rule of thumb, if you need to mock Enum.ToString(), you might want to reconsider what is it that you're doing... because you might be doing something that you will eventually hate to provide support for.
Share what you think about JustTrace & JustMock with us, so we can become even better! You can use the built-in feedback tool inside JustTrace, our forums, or our JustTrace or JustMock portals.