コード例 #1
0
        public void IsEnumType()
        {
            Assert.ThrowsExact <ArgumentNullException>(() => Assert.IsEnumType(null as object));
            Assert.ThrowsExact <ArgumentNullException>(() => Assert.IsEnumType(null as Type));

            Assert.ThrowsExact <AssertionException>(() => Assert.IsEnumType("hello"));
            Assert.ThrowsExact <AssertionException>(() => Assert.IsEnumType(1L));
            Assert.DoesNotThrow(() => Assert.IsEnumType(AttributeTargets.All));
            Assert.ThrowsExact <AssertionException>(() => Assert.IsEnumType(new List <int>()));
            Assert.ThrowsExact <AssertionException>(() => Assert.IsEnumType(new int[0]));

            Assert.ThrowsExact <AssertionException>(() => Assert.IsEnumType <string>());
            Assert.ThrowsExact <AssertionException>(() => Assert.IsEnumType <long>());
            Assert.DoesNotThrow(() => Assert.IsEnumType <AttributeTargets>());
            Assert.ThrowsExact <AssertionException>(() => Assert.IsEnumType <List <int> >());
            Assert.ThrowsExact <AssertionException>(() => Assert.IsEnumType <int[]>());
            Assert.ThrowsExact <AssertionException>(() => Assert.IsEnumType <IEnumerable <int> >());

            Assert.ThrowsExact <AssertionException>(() => Assert.IsEnumType(typeof(string)));
            Assert.ThrowsExact <AssertionException>(() => Assert.IsEnumType(typeof(long)));
            Assert.DoesNotThrow(() => Assert.IsEnumType(typeof(AttributeTargets)));
            Assert.ThrowsExact <AssertionException>(() => Assert.IsEnumType(typeof(List <int>)));
            Assert.ThrowsExact <AssertionException>(() => Assert.IsEnumType(typeof(int[])));
            Assert.ThrowsExact <AssertionException>(() => Assert.IsEnumType(typeof(IEnumerable <int>)));
        }