I am trying to mock this for a unit test... I need help getting all items in here mocked. what I have done does not work and it seems like that the mocks never get hit when they are supposed to. I know that a few of the items are part of our library and may not work on your machines but if you could help please get it on track and I can run it and straighten it out if needed.
public static string GetEnumDisplayName<T>(string enumName)
{
string retVal = null;
MemberInfo memberInfo = typeof(T).GetMember(enumName).FirstOrDefault();
if (memberInfo != null)
{
object[] customAtts = memberInfo.GetCustomAttributes(typeof(IDisplayName), false);
if (customAtts != null && customAtts.Length > 0)
{
retVal = ((IDisplayName)customAtts[0]).DisplayName;
}
//
if (retVal == null)
{
customAtts = memberInfo.GetCustomAttributes(typeof(GeneralDisplayNameAttribute), false);
if (customAtts != null && customAtts.Length > 0)
{
retVal = ((GeneralDisplayNameAttribute)customAtts[0]).DisplayName;
}
}
}
return retVal;
}
public static string GetEnumDisplayName<T>(string enumName)
{
string retVal = null;
MemberInfo memberInfo = typeof(T).GetMember(enumName).FirstOrDefault();
if (memberInfo != null)
{
object[] customAtts = memberInfo.GetCustomAttributes(typeof(IDisplayName), false);
if (customAtts != null && customAtts.Length > 0)
{
retVal = ((IDisplayName)customAtts[0]).DisplayName;
}
//
if (retVal == null)
{
customAtts = memberInfo.GetCustomAttributes(typeof(GeneralDisplayNameAttribute), false);
if (customAtts != null && customAtts.Length > 0)
{
retVal = ((GeneralDisplayNameAttribute)customAtts[0]).DisplayName;
}
}
}
return retVal;
}