コード例 #1
0
        public void IsLessThanTestDateTime()
        {
            string argumentName = string.Empty;
            // correct
            DateTime value = new DateTime(2009, 12, 31, 23, 59, 59);

            try
            {
                ArgumentAssert.IsLessThan(value, new DateTime(2010, 1, 1, 0, 0, 0), argumentName);
            }
            catch (Exception ex)
            {
                Assert.Fail("Assert method must throw no exceptions.\n" + ex.Message);
            }
            // incorrect
            value = new DateTime(1993, 6, 6, 6, 6, 6);
            try
            {
                ArgumentAssert.IsLessThan(value, new DateTime(1992, 6, 6, 6, 6, 6), argumentName);
                Assert.Fail("Assert method must throw ArgumentOutOfRangeException exception.");
            }
            catch (ArgumentOutOfRangeException)
            {
                // test passed
            }
        }
コード例 #2
0
        public void IsLessThanTestDouble()
        {
            string argumentName = string.Empty;
            // correct
            double value = 1;

            try
            {
                ArgumentAssert.IsLessThan(value, 2, argumentName);
            }
            catch (Exception ex)
            {
                Assert.Fail("Assert method must throw no exceptions.\n" + ex.Message);
            }
            // incorrect
            value = 2;
            try
            {
                ArgumentAssert.IsLessThan(value, 1, argumentName);
                Assert.Fail("Assert method must throw ArgumentOutOfRangeException exception.");
            }
            catch (ArgumentOutOfRangeException)
            {
                // test passed
            }
        }