コード例 #1
0
        public void InRange()
        {
            int minValue = 1;
            int maxValue = 10;

            Assert.ThrowsExact <ArgumentNullException>(() => Assert.InRange <string>(null, "z", "z"));
            Assert.ThrowsExact <ArgumentNullException>(() => Assert.InRange <string>("a", null, "z"));
            Assert.ThrowsExact <ArgumentNullException>(() => Assert.InRange <string>("a", "z", null));
            Assert.DoesNotThrow(() => Assert.InRange(2, minValue, maxValue));
            Assert.ThrowsExact <AssertionException>(() => Assert.InRange(minValue, minValue, maxValue));
            Assert.ThrowsExact <AssertionException>(() => Assert.InRange(maxValue, minValue, maxValue));
            Assert.ThrowsExact <AssertionException>(() => Assert.InRange(minValue - 5, minValue, maxValue));
            Assert.DoesNotThrow(() => Assert.InRange(minValue + 5, minValue, maxValue));
            Assert.DoesNotThrow(() => Assert.InRange(maxValue - 5, minValue, maxValue));
            Assert.ThrowsExact <AssertionException>(() => Assert.InRange(maxValue + 5, minValue, maxValue));
        }