예제 #1
0
        public void CutStartReturnsProperString()
        {
            var result  = StringFormatter.CutStart("Test run finished in 1.1 sec. 5 total tests.", 7, numberOfPeriods: 3);
            var result2 = StringFormatter.CutStart("Test run finished in 1.1 sec. 5 total tests.", 12, numberOfPeriods: 3);

            Assert.Equal("...al tests.", result2);
        }
        public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value.Length < 2)
            {
                throw new ArgumentException("2 values should be provided: string and int length.");
            }

            if (value[0] is not string str)
            {
                throw new ArgumentException("First value should be a string (string to shorten).");
            }

            if (value[1] is not int chars)
            {
                throw new ArgumentException("Second value should be an int (number of chars).");
            }

            return(StringFormatter.CutStart(Path.GetFileNameWithoutExtension(str), chars));
        }
예제 #3
0
        public void CutStartReturnsProperNumberOfDots()
        {
            var result = StringFormatter.CutStart("Test run finished in 1.1 sec. 5 total tests.", 10, numberOfPeriods: 6);

            Assert.Equal("......sts.", result);
        }
예제 #4
0
        public void CutStartReturnsProperLength()
        {
            var result = StringFormatter.CutStart("Test run finished in 1.1 sec. 5 total tests.", 12);

            Assert.Equal(12, result.Length);
        }