示例#1
0
        public static void EnumConvert_ToByte()
        {
            Assert.Equal(byte.MinValue, EnumConvert.ToByte(ByteEnum.MinValue));
            Assert.Equal(byte.MaxValue, EnumConvert.ToByte(ByteEnum.MaxValue));

            Assert.Equal(unchecked ((byte)sbyte.MinValue), EnumConvert.ToByte(SByteEnum.MinValue));
            Assert.Equal(unchecked ((byte)ushort.MaxValue), EnumConvert.ToByte(UInt16Enum.MaxValue));
        }
示例#2
0
 public static void EnumConvert_NonEnum()
 {
     Assert.Throws <InvalidCastException>(() => EnumConvert.ToEnum <int>(0));
     Assert.Throws <InvalidCastException>(() => EnumConvert.ToByte(0));
 }