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 GetItems_Success()
        {
            var items = Enum.GetItems <LogLevel>();

            Assert.AreEqual(5, items.Count);
            Assert.AreEqual("致命错误", items[0].Text);
            Assert.AreEqual("1", items[0].Value);
            Assert.AreEqual("信息", items[3].Text);
            Assert.AreEqual("4", items[3].Value);
            Assert.AreEqual("调试", items[4].Text);
            Assert.AreEqual("5", items[4].Value);
        }