Exemplo n.º 1
0
        public void ShortenReturnsCorrectLength()
        {
            var result  = StringFormatter.CutMiddle("Test run finished in 1.1 sec. 5 total tests.", 12);
            var result2 = StringFormatter.CutMiddle("Test run finished in 1.1 sec. 5 total tests.", 20);

            Assert.Equal(12, result.Length);
            Assert.Equal(20, result2.Length);
        }
Exemplo n.º 2
0
        public void ShortenReturnsShortenedString()
        {
            var result  = StringFormatter.CutMiddle("Test run finished in 1.1 sec. 5 total tests.", 5);
            var result2 = StringFormatter.CutMiddle("Test run finished in 1.1 sec. 5 total tests.", 7);

            Assert.Equal("...s.", result);
            Assert.Equal("...sts.", result2);
        }
Exemplo n.º 3
0
        public void ShortenReturnsShortenedStringWithDotsInMiddle()
        {
            var result  = StringFormatter.CutMiddle("Test run finished in 1.1 sec. 5 total tests.", 12);
            var result2 = StringFormatter.CutMiddle("Test run finished in 1.1 sec. 5 total tests.", 10);
            var result3 = StringFormatter.CutMiddle("Test run finished in 1.1 sec. 5 total tests.", 22);

            Assert.Equal("Test...ests.", result);
            Assert.Equal("Tes...sts.", result2);
            Assert.Equal("Test run ...tal tests.", result3);
        }
Exemplo n.º 4
0
 public void ShortenThrowsIfInputIsNull()
 {
     Assert.Throws <ArgumentException>(() => StringFormatter.CutMiddle(null, 5));
 }
Exemplo n.º 5
0
        public void ShortenReturnsEmptyStringWhenPassedEmptyString()
        {
            var result = StringFormatter.CutMiddle("", 123);

            Assert.Equal("", result);
        }
Exemplo n.º 6
0
        public void ShortenReturnsSameIfLengthIsSame()
        {
            var result = StringFormatter.CutMiddle("asddf", 5);

            Assert.Equal("asddf", result);
        }