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

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

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

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