Exemple #1
0
        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());
        }
Exemple #2
0
        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());
        }
Exemple #4
0
        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);
        }
Exemple #5
0
 public void TestSliceArgument(object input, params object[] arguments)
 {
     Assert.Throws <ArgumentException>(() => StringFilters.Slice(FluidValue.Create(input), new FilterArguments(arguments), new TemplateContext()).ToObjectValue());
 }
Exemple #6
0
 public void TestSlice(string expected, object input, params object[] arguments)
 {
     Assert.Equal(expected, StringFilters.Slice(FluidValue.Create(input), new FilterArguments(arguments), new TemplateContext()).ToObjectValue());
 }
Exemple #7
0
 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());
 }
Exemple #8
0
 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());
 }