コード例 #1
0
        public void IsNotType()
        {
            Assert.ThrowsExact <ArgumentNullException>(() => Assert.IsNotType <string>(null));
            Assert.ThrowsExact <AssertionException>(() => Assert.IsNotType <int>(1));
            Assert.DoesNotThrow(() => Assert.IsNotType <int?>(1));
            Assert.DoesNotThrow(() => Assert.IsNotType <int>(1L));
            Assert.DoesNotThrow(() => Assert.IsNotType <int>("hello"));

            Assert.ThrowsExact <ArgumentNullException>(() => Assert.IsNotType(null, typeof(string)));
            Assert.ThrowsExact <ArgumentNullException>(() => Assert.IsNotType("hello", null));
            Assert.ThrowsExact <AssertionException>(() => Assert.IsNotType(1, typeof(int)));
            Assert.DoesNotThrow(() => Assert.IsNotType(1, typeof(int?)));
            Assert.DoesNotThrow(() => Assert.IsNotType(1L, typeof(int)));
            Assert.DoesNotThrow(() => Assert.IsNotType("hello", typeof(int)));
        }