예제 #1
0
 public void When_calling_ThrowIfLargerThan_with_non_null_values_should_not_throw(string testValue)
 {
     AssertThatDoesNotThrow(() => StringGuardiansExtension.ThrowIfLargerThan(testValue, testValue.Length + 1));
 }
예제 #2
0
        public void When_calling_ThrowIfLargerThan_with_null_values_should_throw_ArgumentNullException(string testValue)
        {
            const int testLength = 0;

            AssertThatThrows <ArgumentNullException>(() => StringGuardiansExtension.ThrowIfLargerThan(testValue, testLength));
        }
예제 #3
0
 public void When_calling_ThrowIfLargerThan_with_values_larger_than_length_with_custom_message_exception_message_should_match(string testValue, int testLength)
 {
     AssertThatExceptionMessageShouldMatchCustomMessage <ArgumentLengthLargerThanException>(() => StringGuardiansExtension.ThrowIfLargerThan(testValue, testLength, message: TestCustomExceptionMessage));
 }
예제 #4
0
        public void When_calling_ThrowIfLargerThan_with_values_larger_than_length_with_custom_argumentName_and_custom_message_exception_properties_should_match(string testValue, int testLength)
        {
            const string testValueParamName = nameof(testValue);

            AssertThatExceptionParamNameAndMessageShouldMatch <ArgumentLengthLargerThanException>(() => StringGuardiansExtension.ThrowIfLargerThan(testValue, testLength, testValueParamName, TestCustomExceptionMessage), testValueParamName, TestCustomExceptionMessage);
        }
예제 #5
0
        public void When_calling_ThrowIfLargerThan_with_null_values_with_custom_message_exception_message_should_match(string testValue)
        {
            const int testLength = 0;

            AssertThatExceptionMessageShouldMatchCustomMessage <ArgumentNullException>(() => StringGuardiansExtension.ThrowIfLargerThan(testValue, testLength, message: TestCustomExceptionMessage));
        }
예제 #6
0
        public void When_calling_ThrowIfLargerThan_with_values_larger_than_length_exception_argumentName_and_message_should_match_default(string testValue, int testLength)
        {
            testValue.ThrowIfNull(nameof(testValue));

            var defaultMessage = string.Format(CultureInfo.InvariantCulture, FlabIt.Guardians.Properties.Resources.Exception_ArgumentOfTypeXLargerThanMessageWithParamName, DefaultArgumentName, typeof(string).FullName, testLength, testValue.Length);

            AssertThatExceptionParamNameAndMessageShouldMatchDefaultArgumentName <ArgumentLengthLargerThanException>(() => StringGuardiansExtension.ThrowIfLargerThan(testValue, testLength), defaultMessage);
        }
예제 #7
0
        public void When_calling_ThrowIfLargerThan_with_null_values_with_custom_argumentName_exception_argumentName_should_match(string testValue)
        {
            const string testValueParamName = nameof(testValue);
            const int    testLength         = 0;

            AssertThatExceptionParamNameShouldMatchCustomArgumentName <ArgumentNullException>(() => StringGuardiansExtension.ThrowIfLargerThan(testValue, testLength, testValueParamName), testValueParamName);
        }
예제 #8
0
        public void When_calling_ThrowIfLargerThan_with_null_values_exception_argumentName_and_message_should_match_default(string testValue)
        {
            const int testLength = 0;

            var defaultMessage = string.Format(CultureInfo.InvariantCulture, FlabIt.Guardians.Properties.Resources.Exception_ArgumentNullMessageWithParamName, DefaultArgumentName);

            AssertThatExceptionParamNameAndMessageShouldMatchDefaultArgumentName <ArgumentNullException>(() => StringGuardiansExtension.ThrowIfLargerThan(testValue, testLength), defaultMessage);
        }
예제 #9
0
 public void When_calling_ThrowIfLargerThan_with_values_shorter_than_or_equal_to_length_should_return_input_as_output(string testValue, int testLength)
 {
     AssertThatReturnsInputAsOutput(() => StringGuardiansExtension.ThrowIfLargerThan(testValue, testLength), testValue);
 }
예제 #10
0
 public void When_calling_ThrowIfLargerThan_with_values_not_larger_than_given_length_should_not_throw(string testValue, int testLength)
 {
     AssertThatDoesNotThrow(() => StringGuardiansExtension.ThrowIfLargerThan(testValue, testLength));
 }
예제 #11
0
 public void When_calling_ThrowIfLargerThan_with_values_larger_than_given_length_should_throw_ArgumentLengthLargerThanException(string testValue, int testLength)
 {
     AssertThatThrows <ArgumentLengthLargerThanException>(() => StringGuardiansExtension.ThrowIfLargerThan(testValue, testLength));
 }