public void TestTruncateWords()
 {
     Assert.AreEqual("one two three", StandardFilters.TruncateWords("one two three", 4));
     Assert.AreEqual("one two...", StandardFilters.TruncateWords("one two three", 2));
     Assert.AreEqual("one two three", StandardFilters.TruncateWords("one two three"));
     Assert.AreEqual("Two small (13” x 5.5” x 10” high) baskets fit inside one large basket (13”...", StandardFilters.TruncateWords("Two small (13” x 5.5” x 10” high) baskets fit inside one large basket (13” x 16” x 10.5” high) with cover.", 15));
 }
Esempio n. 2
0
        public void TestTruncateWords()
        {
            Assert.AreEqual(null, StandardFilters.TruncateWords(null));
            Assert.AreEqual("", StandardFilters.TruncateWords(""));
            Assert.AreEqual("one two three", StandardFilters.TruncateWords("one two three", 4));
            Assert.AreEqual("one two...", StandardFilters.TruncateWords("one two three", 2));
            Assert.AreEqual("one two three", StandardFilters.TruncateWords("one two three"));
            Assert.AreEqual("Two small (13” x 5.5” x 10” high) baskets fit inside one large basket (13”...", StandardFilters.TruncateWords("Two small (13” x 5.5” x 10” high) baskets fit inside one large basket (13” x 16” x 10.5” high) with cover.", 15));

            Helper.AssertTemplateResult(expected: "Ground control to...", template: "{{ \"Ground control to Major Tom.\" | truncate_words: 3}}");
            Helper.AssertTemplateResult(expected: "Ground control to--", template: "{{ \"Ground control to Major Tom.\" | truncate_words: 3, \"--\"}}");
            Helper.AssertTemplateResult(expected: "Ground control to", template: "{{ \"Ground control to Major Tom.\" | truncate_words: 3, \"\"}}");
            Helper.AssertTemplateResult(expected: "...", template: "{{ \"Ground control to Major Tom.\" | truncate_words: 0}}");
            Helper.AssertTemplateResult(expected: "...", template: "{{ \"Ground control to Major Tom.\" | truncate_words: -1}}");
            Helper.AssertTemplateResult(expected: "Liquid error: Value was either too large or too small for an Int32.", template: $"{{{{ \"Ground control to Major Tom.\" | truncate_words: {((long)int.MaxValue) + 1}}}}}");
        }
Esempio n. 3
0
        public void TestTruncateWords()
        {
            Assert.AreEqual(null, StandardFilters.TruncateWords(null));
            Assert.AreEqual("", StandardFilters.TruncateWords(""));
            Assert.AreEqual("one two three", StandardFilters.TruncateWords("one two three", 4));
            Assert.AreEqual("one two...", StandardFilters.TruncateWords("one two three", 2));
            Assert.AreEqual("one two three", StandardFilters.TruncateWords("one two three"));
            Assert.AreEqual("Two small (13” x 5.5” x 10” high) baskets fit inside one large basket (13”...", StandardFilters.TruncateWords("Two small (13” x 5.5” x 10” high) baskets fit inside one large basket (13” x 16” x 10.5” high) with cover.", 15));

            Helper.AssertTemplateResult(expected: "Ground control to...", template: "{{ 'Ground control to Major Tom.' | truncate_words:3 }}");
            Helper.AssertTemplateResult(expected: "Ground control to--", template: "{{ 'Ground control to Major Tom.' | truncate_words:3, '--' }}");
            Helper.AssertTemplateResult(expected: "Ground control to", template: "{{ 'Ground control to Major Tom.' | truncate_words:3, '' }}");
            Helper.AssertTemplateResult(expected: "...", template: "{{ 'Ground control to Major Tom.' | truncate_words:0 }}");
            Helper.AssertTemplateResult(expected: "Liquid error: words parameter of truncate-words filter is out of the range of valid positive integers.", template: "{{ 'Ground control to Major Tom.' | truncate_words:-1 }}");
            Helper.AssertTemplateResult(expected: "Liquid error: Value was either too large or too small for an Int32.", template: "{{ 'Ground control to Major Tom.' | truncate_words:" + int.MaxValue + 1 + " }}");
        }