Beispiel #1
0
        public void ArgumentInRangeTimeOnlyTest()
        {
            var lowerValue           = new TimeOnly(1, 3, 3);
            var upperValue           = new TimeOnly(10, 3, 3);
            var testValue            = new TimeOnly(5, 3, 20);
            var outOfRangeLowerValue = new TimeOnly(1, 3, 3);
            var outOfRangeUpperValue = new TimeOnly(2, 3, 3);

            try
            {
                var result = testValue.ArgumentInRange(lowerValue, upperValue);

                Assert.AreEqual(result, testValue);
            }
            catch
            {
                Assert.Fail();
            }

            // Test Exception
            _ = Assert.ThrowsException <ArgumentOutOfRangeException>(() => testValue.ArgumentInRange(outOfRangeLowerValue, outOfRangeUpperValue));
        }
Beispiel #2
0
        public void ArgumentInRangeTimeOnlyWithDefaultTest()
        {
            var lowerValue   = new TimeOnly(1, 3, 3);
            var upperValue   = new TimeOnly(2, 3, 3);
            var testValue    = new TimeOnly(5, 3, 20);
            var defaultValue = new TimeOnly(2, 3, 3);

            try
            {
                var result = testValue.ArgumentInRange(lowerValue, upperValue, defaultValue);

                Assert.AreEqual(result, defaultValue);
            }
            catch
            {
                Assert.Fail();
            }
        }