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()); }
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()); }
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()); }
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()); }
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()); }