Exemplo n.º 1
0
        public void IsNotGenericType()
        {
            Assert.ThrowsExact <ArgumentNullException>(() => Assert.IsNotGenericType(null as object));
            Assert.ThrowsExact <ArgumentNullException>(() => Assert.IsNotGenericType(null as Type));

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

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

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