public void Truncate(string input, int size, string output)
        {
            var source    = new StringValue(input);
            var arguments = new FilterArguments().Add(new NumberValue(size));
            var context   = new TemplateContext();
            var result    = StringFilters.Truncate(source, arguments, context);

            Assert.Equal(output, result.ToStringValue());
        }
Exemple #2
0
        public void TruncateShortString()
        {
            var input = new StringValue("Hello");

            var arguments = new FilterArguments().Add(new NumberValue(5)).Add(new StringValue("..."));
            var context   = new TemplateContext();

            var result = StringFilters.Truncate(input, arguments, context);

            Assert.Equal("Hello", result.ToStringValue());
        }
Exemple #3
0
        public void TruncateNullString()
        {
            var input = new StringValue(null);

            var arguments = new FilterArguments().Add(new NumberValue(5)).Add(new StringValue("..."));
            var context   = new TemplateContext();

            var result = StringFilters.Truncate(input, arguments, context);

            Assert.Null(result.ToStringValue());
        }
Exemple #4
0
 public void TestTruncate(string expected, object input, object length = null, object truncate = null)
 {
     Assert.Equal(expected, StringFilters.Truncate(FluidValue.Create(input), new FilterArguments(length, truncate), new TemplateContext()).ToObjectValue());
 }
Exemple #5
0
 public void TestTruncate(string expected, object input, object length = null, object truncate = null)
 {
     Assert.Equal(expected, StringFilters.Truncate(FluidValue.Create(input, TemplateOptions.Default), new FilterArguments(FluidValue.Create(length, TemplateOptions.Default), FluidValue.Create(truncate, TemplateOptions.Default)), new TemplateContext()).Result.ToObjectValue());
 }