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); }
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); }
public void Test_GetItems_Validate() { AssertHelper.Throws <InvalidOperationException>(() => { Enum.GetItems <Sample>(); }, "类型 Bing.Tests.Samples.Sample 不是枚举"); }