/// <summary> /// 生成随机枚举 /// </summary> /// <typeparam name="T">枚举</typeparam> public T GenerateEnum <T>() { var list = Enum.GetItems <T>(); int index = _random.GetInt(0, list.Count); return(Enum.GetInstance <T>(list[index].Value)); }
public void TestGetInstance_ArgumentIsEmpty_Throw() { try { Enum.GetInstance <LogLevel>(string.Empty); } catch (ArgumentNullException ex) { Assert.IsTrue(ex.Message.Contains("member")); throw; } }
public void GetInstance_Name_Nullable() { Assert.AreEqual(DebugInstance, Enum.GetInstance <LogLevel?>(DebugName)); }
public void GetInstance_Value() { Assert.AreEqual(DebugInstance, Enum.GetInstance <LogLevel>(DebugValue)); }