Beispiel #1
0
        /// <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));
        }
Beispiel #2
0
 public void TestGetInstance_ArgumentIsEmpty_Throw()
 {
     try {
         Enum.GetInstance <LogLevel>(string.Empty);
     }
     catch (ArgumentNullException ex) {
         Assert.IsTrue(ex.Message.Contains("member"));
         throw;
     }
 }
Beispiel #3
0
 public void GetInstance_Name_Nullable()
 {
     Assert.AreEqual(DebugInstance, Enum.GetInstance <LogLevel?>(DebugName));
 }
Beispiel #4
0
 public void GetInstance_Value()
 {
     Assert.AreEqual(DebugInstance, Enum.GetInstance <LogLevel>(DebugValue));
 }