public void Slice(object input, object[] arguments, string expected) { var filterInput = FluidValue.Create(input); var filterArguments = new FilterArguments(arguments); var context = new TemplateContext(); var result = StringFilters.Slice(filterInput, filterArguments, context); Assert.Equal(expected, result.ToStringValue()); }
public void SliceOutsideBounds(object input, object[] arguments, string expected) { var filterInput = FluidValue.Create(input, TemplateOptions.Default); var filterArguments = new FilterArguments(arguments.Select(x => FluidValue.Create(x, TemplateOptions.Default)).ToArray()); var context = new TemplateContext(); var result = StringFilters.Slice(filterInput, filterArguments, context); Assert.Equal(expected, result.Result.ToStringValue()); }
public void Slice() { var input = new StringValue("hello"); var arguments = new FilterArguments().Add(new NumberValue(-3)).Add(new NumberValue(3)); var context = new TemplateContext(); var result = StringFilters.Slice(input, arguments, context); Assert.Equal("llo", result.ToStringValue()); }
public void TestSliceOnArrays(string expected, params object[] arguments) { var foobar = new object [] { 'f', 'o', 'o', 'b', 'a', 'r' }; var result = StringFilters.Slice(FluidValue.Create(foobar), new FilterArguments(arguments), new TemplateContext()); Assert.IsType <ArrayValue>(result); string resultString = ""; foreach (var c in result.ToObjectValue() as object[]) { resultString += c.ToString(); } Assert.Equal(expected, resultString); }
public void TestSliceArgument(object input, params object[] arguments) { Assert.Throws <ArgumentException>(() => StringFilters.Slice(FluidValue.Create(input), new FilterArguments(arguments), new TemplateContext()).ToObjectValue()); }
public void TestSlice(string expected, object input, params object[] arguments) { Assert.Equal(expected, StringFilters.Slice(FluidValue.Create(input), new FilterArguments(arguments), new TemplateContext()).ToObjectValue()); }
public void TestSliceArgument(object input, params object[] arguments) { Assert.Throws <ArgumentException>(() => StringFilters.Slice(FluidValue.Create(input, TemplateOptions.Default), new FilterArguments(arguments.Select(x => FluidValue.Create(x, TemplateOptions.Default)).ToArray()), new TemplateContext()).Result.ToObjectValue()); }
public void TestSlice(string expected, object input, params object[] arguments) { Assert.Equal(expected, StringFilters.Slice(FluidValue.Create(input, TemplateOptions.Default), new FilterArguments(arguments.Select(x => FluidValue.Create(x, TemplateOptions.Default)).ToArray()), new TemplateContext()).Result.ToObjectValue()); }