<commit_before>﻿using NUnit.Framework;

namespace CurrencyRates.Extension
{
    [TestFixture]
    class StringUtilsTest
    {
        [TestCaseSource("TruncateTestCases")]
        public void TestTruncate(string value, int maxLength, string truncated)
        {
            Assert.AreEqual(truncated, value.Truncate(maxLength));
        }

        static object[] TruncateTestCases =
        {
            new object[] {"", 1, ""},
            new object[] {"Example", 4, "E..."},
            new object[] {"Example", 6, "Exa..."},
            new object[] {"Example", 7, "Example"},
            new object[] {"Example", 8, "Example"}
        };

        [Test]
        public void TestTruncateThrowsException()
        {
            Assert.Throws<System.ArgumentOutOfRangeException>(
                () => "Example".Truncate(3)    
            );
        }
    }
}<commit_msg>Add better exception check in StringUtilsTest<commit_after>﻿using NUnit.Framework;

namespace CurrencyRates.Extension
{
    [TestFixture]
    class StringUtilsTest
    {
        [TestCaseSource("TruncateTestCases")]
        public void TestTruncate(string value, int maxLength, string truncated)
        {
            Assert.AreEqual(truncated, value.Truncate(maxLength));
        }

        static object[] TruncateTestCases =
        {
            new object[] {"", 1, ""},
            new object[] {"Example", 4, "E..."},
            new object[] {"Example", 6, "Exa..."},
            new object[] {"Example", 7, "Example"},
            new object[] {"Example", 8, "Example"}
        };

        [Test]
        public void TestTruncateThrowsException()
        {
            var exception = Assert.Throws<System.ArgumentOutOfRangeException>(
                () => "Example".Truncate(3)    
            );

            Assert.AreEqual("maxLength", exception.ParamName);
            StringAssert.Contains("maxLength must be at least 4", exception.Message);
        }
    }
}
{'fraction_non_alphanumeric': 0.13268442622950818, 'fraction_numerical': 0.00665983606557377, 'mean_word_length': 2.00924499229584, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5215689', 'n_tokens_mistral': 553, 'n_tokens_neox': 529, 'n_words': 116}