public void HasLengthBetween_WhenStringIsNull_ThrowsArgumentNullException()
        {
            string value = null;

            AssertIsNotNull(
                () => Ensure.That(value, ParamName).HasLengthBetween(1, 2),
                () => EnsureArg.HasLengthBetween(value, 1, 2, ParamName));
        }
        public void HasLengthBetween_WhenStringIsHighLimit_It_should_not_throw()
        {
            const int low   = 2;
            const int high  = 4;
            var       value = new string('a', high);

            ShouldNotThrow(
                () => Ensure.That(value, ParamName).HasLengthBetween(low, high),
                () => EnsureArg.HasLengthBetween(value, low, high, ParamName));
        }
        public void HasLengthBetween_WhenStringIsToLong_ThrowsArgumentException()
        {
            const int low   = 2;
            const int high  = 4;
            var       value = new string('a', high + 1);

            ShouldThrow <ArgumentException>(
                string.Format(ExceptionMessages.Strings_HasLengthBetween_Failed_ToLong, low, high, value.Length),
                () => Ensure.That(value, ParamName).HasLengthBetween(2, high),
                () => EnsureArg.HasLengthBetween(value, low, high, ParamName));
        }
Exemplo n.º 4
0
        public void HasLengthBetween_WhenStringIsHighLimit_It_should_not_throw()
        {
            const int low   = 2;
            const int high  = 4;
            var       value = new string('a', high);

            var returnedValue = Ensure.That(value, ParamName).HasLengthBetween(low, high);

            AssertReturnedAsExpected(returnedValue, value);

            Action a = () => EnsureArg.HasLengthBetween(value, low, high, ParamName);

            a.ShouldNotThrow();
        }