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

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

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

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