Beispiel #1
0
        public void Test_GetItems_Nullable_Type()
        {
            var items = Enum.GetItems(typeof(EnumSample?));

            Assert.Equal(5, items.Count);
            Assert.Equal("A", items[0].Text);
            Assert.Equal(1, items[0].Value);
            Assert.Equal("D4", items[3].Text);
            Assert.Equal(4, items[3].Value);
            Assert.Equal("E5", items[4].Text);
            Assert.Equal(5, items[4].Value);
        }
Beispiel #2
0
        public void Test_GetItems()
        {
            var items = Enum.GetItems <EnumSample>();

            Assert.Equal(5, items.Count);
            Assert.Equal("A", items[0].Text);
            Assert.Equal(1, items[0].Value);
            Assert.Equal("D4", items[3].Text);
            Assert.Equal(4, items[3].Value);
            Assert.Equal("E5", items[4].Text);
            Assert.Equal(5, items[4].Value);
        }
Beispiel #3
0
 public void Test_GetItems_Validate()
 {
     AssertHelper.Throws <InvalidOperationException>(() => {
         Enum.GetItems <Sample>();
     }, "类型 Bing.Tests.Samples.Sample 不是枚举");
 }