Ejemplo n.º 1
0
        public async Task TestModulo()
        {
            await Helper.AssertTemplateResultAsync("1", "{{ 3 | modulo:2 }}");

            Assert.Null(StandardFilters.Modulo(null, 3));
            Assert.Null(StandardFilters.Modulo(4, null));
        }
Ejemplo n.º 2
0
        public void TestAbs()
        {
            Assert.AreEqual(0, StandardFilters.Abs("notNumber"));
            Assert.AreEqual(10, StandardFilters.Abs(10));
            Assert.AreEqual(5, StandardFilters.Abs(-5));
            Assert.AreEqual(19.86, StandardFilters.Abs(19.86));
            Assert.AreEqual(19.86, StandardFilters.Abs(-19.86));
            Assert.AreEqual(10, StandardFilters.Abs("10"));
            Assert.AreEqual(5, StandardFilters.Abs("-5"));
            Assert.AreEqual(30.60, StandardFilters.Abs("30.60"));
            Assert.AreEqual(0, StandardFilters.Abs("30.60a"));

            Helper.AssertTemplateResult(
                expected: "17",
                template: "{{ -17 | abs }}");
            Helper.AssertTemplateResult(
                expected: "17",
                template: "{{ 17 | abs }}");
            Helper.AssertTemplateResult(
                expected: "4",
                template: "{{ 4 | abs }}");
            Helper.AssertTemplateResult(
                expected: "19.86",
                template: "{{ '-19.86' | abs }}");
        }
Ejemplo n.º 3
0
 public void TestJoin()
 {
     Assert.AreEqual(null, StandardFilters.Join(null));
     Assert.AreEqual("", StandardFilters.Join(""));
     Assert.AreEqual("1 2 3 4", StandardFilters.Join(new[] { 1, 2, 3, 4 }));
     Assert.AreEqual("1 - 2 - 3 - 4", StandardFilters.Join(new[] { 1, 2, 3, 4 }, " - "));
 }
Ejemplo n.º 4
0
        public void TestTimes()
        {
            using (CultureHelper.SetCulture("en-GB"))
            {
                Helper.AssertTemplateResult("12", "{{ 3 | times:4 }}");
                Helper.AssertTemplateResult("125", "{{ 10 | times:12.5 }}");
                Helper.AssertTemplateResult("125", "{{ 10.0 | times:12.5 }}");
                Helper.AssertTemplateResult("125", "{{ 12.5 | times:10 }}");
                Helper.AssertTemplateResult("125", "{{ 12.5 | times:10.0 }}");
                Helper.AssertTemplateResult("foofoofoofoo", "{{ 'foo' | times:4 }}");

                // Test against overflows when we try to be precise but the result exceeds the range of the input type.
                Helper.AssertTemplateResult(((double)((decimal.MaxValue / 100) + (decimal).1) * (double)((decimal.MaxValue / 100) + (decimal).1)).ToString(), $"{{{{ {(decimal.MaxValue / 100) + (decimal).1} | times:{(decimal.MaxValue / 100) + (decimal).1} }}}}");

                // Test against overflows going beyond the double precision float type's range
                Helper.AssertTemplateResult(double.NegativeInfinity.ToString(), $"{{{{ 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.0 | times:-12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.0 }}}}");
                Helper.AssertTemplateResult(double.PositiveInfinity.ToString(), $"{{{{ 12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.0 | times:12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890.0 }}}}");

                // Ensures no underflow exception is thrown when the result doesn't fit the precision of double.
                Helper.AssertTemplateResult("0", $"{{{{ 0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 | times:0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001 }}}}");
            }

            Assert.AreEqual(8.43, StandardFilters.Times(0.843m, 10));
            Assert.AreEqual(412, StandardFilters.Times(4.12m, 100));
            Assert.AreEqual(7556.3, StandardFilters.Times(7.5563m, 1000));
        }
Ejemplo n.º 5
0
 public void TestUrlencode()
 {
     Assert.AreEqual("http%3A%2F%2Fdotliquidmarkup.org%2F", StandardFilters.UrlEncode("http://dotliquidmarkup.org/"));
     Assert.AreEqual("Tetsuro+Takara", StandardFilters.UrlEncode("Tetsuro Takara"));
     Assert.AreEqual("john%40liquid.com", StandardFilters.UrlEncode("*****@*****.**"));
     Assert.AreEqual(null, StandardFilters.UrlEncode(null));
 }
Ejemplo n.º 6
0
        public void TestStrFTime()
        {
            Liquid.UseRubyDateFormat = true;
            DateTimeFormatInfo dateTimeFormat = CultureInfo.CurrentCulture.DateTimeFormat;

            Assert.AreEqual(dateTimeFormat.GetMonthName(5), StandardFilters.Date(DateTime.Parse("2006-05-05 10:00:00"), "%B"));
            Assert.AreEqual(dateTimeFormat.GetMonthName(6), StandardFilters.Date(DateTime.Parse("2006-06-05 10:00:00"), "%B"));
            Assert.AreEqual(dateTimeFormat.GetMonthName(7), StandardFilters.Date(DateTime.Parse("2006-07-05 10:00:00"), "%B"));

            Assert.AreEqual(dateTimeFormat.GetMonthName(5), StandardFilters.Date("2006-05-05 10:00:00", "%B"));
            Assert.AreEqual(dateTimeFormat.GetMonthName(6), StandardFilters.Date("2006-06-05 10:00:00", "%B"));
            Assert.AreEqual(dateTimeFormat.GetMonthName(7), StandardFilters.Date("2006-07-05 10:00:00", "%B"));

            Assert.AreEqual("05/07/2006 10:00:00", StandardFilters.Date("05/07/2006 10:00:00", string.Empty));
            Assert.AreEqual("05/07/2006 10:00:00", StandardFilters.Date("05/07/2006 10:00:00", null));

            Assert.AreEqual("07/05/2006", StandardFilters.Date("2006-07-05 10:00:00", "%m/%d/%Y"));

            Assert.AreEqual("07/16/2004", StandardFilters.Date("Fri Jul 16 2004 01:00:00", "%m/%d/%Y"));

            Assert.AreEqual(null, StandardFilters.Date(null, "%M"));

            Assert.AreEqual("hi", StandardFilters.Date("hi", "%M"));

            Template template = Template.Parse(@"{{ hi | date:""%M"" }}");

            Assert.AreEqual("hi", template.Render(Hash.FromAnonymousObject(new { hi = "hi" })));
        }
Ejemplo n.º 7
0
        public void TestFirstLast()
        {
            Assert.Null(StandardFilters.First(null));
            Assert.Null(StandardFilters.Last(null));
            Assert.AreEqual(1, StandardFilters.First(new[] { 1, 2, 3 }));
            Assert.AreEqual(3, StandardFilters.Last(new[] { 1, 2, 3 }));
            Assert.Null(StandardFilters.First(new object[] { }));
            Assert.Null(StandardFilters.Last(new object[] { }));

            Helper.AssertTemplateResult(
                expected: ".",
                template: "{{ 'Ground control to Major Tom.' | last }}");
            Helper.AssertTemplateResult(
                expected: "Tom.",
                template: "{{ 'Ground control to Major Tom.' | split: ' ' | last }}");
            Helper.AssertTemplateResult(
                expected: "tiger",
                template: "{% assign my_array = 'zebra, octopus, giraffe, tiger' | split: ', ' %}{{ my_array.last }}");
            Helper.AssertTemplateResult(
                expected: "There goes a tiger!",
                template: "{% assign my_array = 'zebra, octopus, giraffe, tiger' | split: ', ' %}{% if my_array.last == 'tiger' %}There goes a tiger!{% endif %}");

            Helper.AssertTemplateResult(
                expected: "G",
                template: "{{ 'Ground control to Major Tom.' | first }}");
            Helper.AssertTemplateResult(
                expected: "Ground",
                template: "{{ 'Ground control to Major Tom.' | split: ' ' | first }}");
            Helper.AssertTemplateResult(
                expected: "zebra",
                template: "{% assign my_array = 'zebra, octopus, giraffe, tiger' | split: ', ' %}{{ my_array.first }}");
            Helper.AssertTemplateResult(
                expected: "There goes a zebra!",
                template: "{% assign my_array = 'zebra, octopus, giraffe, tiger' | split: ', ' %}{% if my_array.first == 'zebra' %}There goes a zebra!{% endif %}");
        }
Ejemplo n.º 8
0
        public static string FullClassName(object input, string propName, Context context = null)
        {
            propName = StandardFilters.Capitalize(propName);

            if (input is string)
            {
                return(Namespace("" + input) + "." + ClassName("" + input));
            }
            else
            {
                Context ctx;
                var     schema = GetSchema(input, out ctx);
                if (schema != null)
                {
                    context = context ?? ctx;

                    if (schema.IsAtomicType())
                    {
                        return(schema.GetSchemaClrType());
                    }
                    else if (schema.Enum != null)
                    {
                        return(ClassEnumsTag.AddEnum(context, propName, schema));
                    }
                    else
                    {
                        return("--not a supported type: " + schema);
                    }
                }
            }

            return("--FullClassName(object input), unknown input type: " + input.GetType().Name);
        }
Ejemplo n.º 9
0
 public void TestCapitalize()
 {
     Assert.AreEqual(null, StandardFilters.Capitalize(null));
     Assert.AreEqual("", StandardFilters.Capitalize(""));
     Assert.AreEqual(" ", StandardFilters.Capitalize(" "));
     Assert.AreEqual("That Is One Sentence.", StandardFilters.Capitalize("That is one sentence."));
 }
Ejemplo n.º 10
0
        private void RenderToNullRenderer(IDESCombineCB audioCallback, IDESCombineCB videoCallback)
        {
            int hr;

            ICaptureGraphBuilder2 icgb = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();

            try
            {
                hr = icgb.SetFiltergraph(_graph);
                DESError.ThrowExceptionForHR(hr);

                IBaseFilter audioDest = StandardFilters.RenderNull(_dc, _graph);
                IBaseFilter videoDest = StandardFilters.RenderNull(_dc, _graph);

                try
                {
                    RenderGroups(icgb, null, null, audioDest, videoDest, audioCallback, videoCallback);
                }
                finally
                {
                    if (audioDest != null)
                    {
                        Marshal.ReleaseComObject(audioDest);
                    }
                    if (videoDest != null)
                    {
                        Marshal.ReleaseComObject(videoDest);
                    }
                }
            }
            finally
            {
                Marshal.ReleaseComObject(icgb);
            }
        }
Ejemplo n.º 11
0
 public ItemsHolderItemSets() : base(AssetProvider.ItemSets.Values.ToList())
 {
     StandardFilters.Add("Upgrades", new UpgradesFilter(this));
     StandardFilters.Add("Equipped", new EquippedFilter(this));
     StandardFilters.Add("SearchText", new SearchTextFilter(this));
     StandardFilters.Add("TargetBuilding", new TargetBuildingFilter(this));
 }
Ejemplo n.º 12
0
 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));
 }
Ejemplo n.º 13
0
 public void TestTruncate()
 {
     Assert.AreEqual("1234...", StandardFilters.Truncate("1234567890", 7));
     Assert.AreEqual("1234567890", StandardFilters.Truncate("1234567890", 20));
     Assert.AreEqual("...", StandardFilters.Truncate("1234567890", 0));
     Assert.AreEqual("1234567890", StandardFilters.Truncate("1234567890"));
 }
Ejemplo n.º 14
0
 public void TestFirstLast()
 {
     Assert.AreEqual(1, StandardFilters.First(new[] { 1, 2, 3 }));
     Assert.AreEqual(3, StandardFilters.Last(new[] { 1, 2, 3 }));
     Assert.AreEqual(null, StandardFilters.First(new object[] { }));
     Assert.AreEqual(null, StandardFilters.Last(new object[] { }));
 }
Ejemplo n.º 15
0
 public void TestCurrencyFromDoubleInput()
 {
     Assert.AreEqual("$6.85", StandardFilters.Currency(6.8458, "en-US"));
     Assert.AreEqual("$6.72", StandardFilters.Currency(6.72, "en-CA"));
     Assert.AreEqual("6.000.000,00 €", StandardFilters.Currency(6000000, "de-DE"));
     Assert.AreEqual("6.000.000,78 €", StandardFilters.Currency(6000000.78, "de-DE"));
 }
Ejemplo n.º 16
0
 public void TestEscape()
 {
     Assert.AreEqual(null, StandardFilters.Escape(null));
     Assert.AreEqual("", StandardFilters.Escape(""));
     Assert.AreEqual("&lt;strong&gt;", StandardFilters.Escape("<strong>"));
     Assert.AreEqual("&lt;strong&gt;", StandardFilters.H("<strong>"));
 }
Ejemplo n.º 17
0
        public void TestDate()
        {
            Liquid.UseRubyDateFormat = false;
            DateTimeFormatInfo dateTimeFormat = CultureInfo.CurrentCulture.DateTimeFormat;

            Assert.AreEqual(dateTimeFormat.GetMonthName(5), StandardFilters.Date(DateTime.Parse("2006-05-05 10:00:00"), "MMMM"));
            Assert.AreEqual(dateTimeFormat.GetMonthName(6), StandardFilters.Date(DateTime.Parse("2006-06-05 10:00:00"), "MMMM"));
            Assert.AreEqual(dateTimeFormat.GetMonthName(7), StandardFilters.Date(DateTime.Parse("2006-07-05 10:00:00"), "MMMM"));

            Assert.AreEqual(dateTimeFormat.GetMonthName(5), StandardFilters.Date("2006-05-05 10:00:00", "MMMM"));
            Assert.AreEqual(dateTimeFormat.GetMonthName(6), StandardFilters.Date("2006-06-05 10:00:00", "MMMM"));
            Assert.AreEqual(dateTimeFormat.GetMonthName(7), StandardFilters.Date("2006-07-05 10:00:00", "MMMM"));

            Assert.AreEqual("05/07/2006 10:00:00", StandardFilters.Date("05/07/2006 10:00:00", string.Empty));
            Assert.AreEqual("05/07/2006 10:00:00", StandardFilters.Date("05/07/2006 10:00:00", null));

            Assert.AreEqual(new DateTime(2006, 7, 5).ToString("MM/dd/yyyy"), StandardFilters.Date("2006-07-05 10:00:00", "MM/dd/yyyy"));

            Assert.AreEqual(new DateTime(2004, 7, 16).ToString("MM/dd/yyyy"), StandardFilters.Date("Fri Jul 16 2004 01:00:00", "MM/dd/yyyy"));

            Assert.AreEqual(null, StandardFilters.Date(null, "MMMM"));

            Assert.AreEqual("hi", StandardFilters.Date("hi", "MMMM"));

            Assert.AreEqual(DateTime.Now.ToString("MM/dd/yyyy"), StandardFilters.Date("now", "MM/dd/yyyy"));
            Assert.AreEqual(DateTime.Now.ToString("MM/dd/yyyy"), StandardFilters.Date("today", "MM/dd/yyyy"));
            Assert.AreEqual(DateTime.Now.ToString("MM/dd/yyyy"), StandardFilters.Date("Now", "MM/dd/yyyy"));
            Assert.AreEqual(DateTime.Now.ToString("MM/dd/yyyy"), StandardFilters.Date("Today", "MM/dd/yyyy"));

            Template template = Template.Parse(@"{{ hi | date:""MMMM"" }}");

            Assert.AreEqual("hi", template.Render(Hash.FromAnonymousObject(new { hi = "hi" })));
        }
Ejemplo n.º 18
0
 public void TestSort()
 {
     CollectionAssert.AreEqual(new string[] { }, StandardFilters.Sort(new string[] { }));
     CollectionAssert.AreEqual(new[] { 1, 2, 3, 4 }, StandardFilters.Sort(new[] { 4, 3, 2, 1 }));
     CollectionAssert.AreEqual(new[] { new { a = 1 }, new { a = 2 }, new { a = 3 }, new { a = 4 } },
                               StandardFilters.Sort(new[] { new { a = 4 }, new { a = 3 }, new { a = 1 }, new { a = 2 } }, "a"));
 }
 public BuildingsHolderItems() : base(() => ProgrammSettings.CurrentSavegame?.GameObjects?.GameObjects)
 {
     StandardFilters.Add("Player", new PlayerFilter(this));
     StandardFilters.Add("Session", new SessionsFilter(this));
     StandardFilters.Add("Area", new AreasFilter(this));
     StandardFilters.Add("Text", new SearchTextFilter(this));
 }
Ejemplo n.º 20
0
        public void RenderToWavDest(
            string outputFile,
            IBaseFilter audioCompressor,
            AMMediaType mediaType,
            IDESCombineCB audioCallback)
        {
            if (audioCompressor != null)
            {
                _dc.Add(audioCompressor);
            }

            int hr;

            if (_firstAudioGroup == null)
            {
                throw new SplicerException("No audio stream to render");
            }

            if (outputFile == null)
            {
                throw new SplicerException("Output file name cannot be null");
            }

            // Contains useful routines for creating the graph
            ICaptureGraphBuilder2 icgb = (ICaptureGraphBuilder2) new CaptureGraphBuilder2();

            _dc.Add(icgb);

            try
            {
                hr = icgb.SetFiltergraph(_graph);
                DESError.ThrowExceptionForHR(hr);

                IBaseFilter wavDestFilter = StandardFilters.RenderWavDest(_dc, _graph);
                IBaseFilter fileSink      = StandardFilters.RenderFileDestination(_dc, _graph, outputFile);

                try
                {
                    RenderGroups(icgb, audioCompressor, null, wavDestFilter, audioCallback, null);

                    FilterGraphTools.ConnectFilters(_graph, wavDestFilter, fileSink, true);

                    // if supplied, apply the media type to the filter
                    if (mediaType != null)
                    {
                        FilterGraphTools.SetFilterFormat(mediaType, audioCompressor);
                    }
                }
                finally
                {
                    Marshal.ReleaseComObject(wavDestFilter);
                    Marshal.ReleaseComObject(fileSink);
                }
            }
            finally
            {
                Marshal.ReleaseComObject(icgb);
            }
        }
Ejemplo n.º 21
0
 public void TestLStrip()
 {
     Assert.AreEqual("test  ", StandardFilters.Lstrip("  test  "));
     Assert.AreEqual("test", StandardFilters.Lstrip("   test"));
     Assert.AreEqual("test   ", StandardFilters.Lstrip("test   "));
     Assert.AreEqual("test", StandardFilters.Lstrip("test"));
     Assert.AreEqual(null, StandardFilters.Lstrip(null));
 }
Ejemplo n.º 22
0
 public void TestReplace()
 {
     Assert.Null(StandardFilters.Replace(null, "a", "b"));
     Assert.AreEqual("", StandardFilters.Replace("", "a", "b"));
     Assert.AreEqual("a a a a", StandardFilters.Replace("a a a a", null, "b"));
     Assert.AreEqual("a a a a", StandardFilters.Replace("a a a a", "", "b"));
     Assert.AreEqual("b b b b", StandardFilters.Replace("a a a a", "a", "b"));
 }
Ejemplo n.º 23
0
 public void TestDividedBy()
 {
     Helper.AssertTemplateResult("4", "{{ 12 | divided_by:3 }}");
     Helper.AssertTemplateResult("4", "{{ 14 | divided_by:3 }}");
     Helper.AssertTemplateResult("5", "{{ 15 | divided_by:3 }}");
     Assert.Null(StandardFilters.DividedBy(null, 3));
     Assert.Null(StandardFilters.DividedBy(4, null));
 }
Ejemplo n.º 24
0
        public void TestMap()
        {
            CollectionAssert.AreEqual(new string[] { }, StandardFilters.Map(new string[] { }, "a"));
            CollectionAssert.AreEqual(new[] { 1, 2, 3, 4 },
                                      StandardFilters.Map(new[] { new { a = 1 }, new { a = 2 }, new { a = 3 }, new { a = 4 } }, "a"));
            Helper.AssertTemplateResult("abc", "{{ ary | map:'foo' | map:'bar' }}",
                                        Hash.FromAnonymousObject(
                                            new
            {
                ary =
                    new[]
                {
                    Hash.FromAnonymousObject(new { foo = Hash.FromAnonymousObject(new { bar = "a" }) }), Hash.FromAnonymousObject(new { foo = Hash.FromAnonymousObject(new { bar = "b" }) }),
                    Hash.FromAnonymousObject(new { foo = Hash.FromAnonymousObject(new { bar = "c" }) })
                }
            }));
            CollectionAssert.AreEqual(new[] { new { a = 1 }, new { a = 2 }, new { a = 3 }, new { a = 4 } },
                                      StandardFilters.Map(new[] { new { a = 1 }, new { a = 2 }, new { a = 3 }, new { a = 4 } }, "b"));

            Assert.AreEqual(null, StandardFilters.Map(null, "a"));
            CollectionAssert.AreEqual(new object[] { null }, StandardFilters.Map(new object[] { null }, "a"));

            var hash = Hash.FromAnonymousObject(new
            {
                ary = new[] {
                    new Helper.DataObject {
                        PropAllowed = "a", PropDisallowed = "x"
                    },
                    new Helper.DataObject {
                        PropAllowed = "b", PropDisallowed = "y"
                    },
                    new Helper.DataObject {
                        PropAllowed = "c", PropDisallowed = "z"
                    },
                }
            });

            Helper.AssertTemplateResult("abc", "{{ ary | map:'prop_allowed' | join:'' }}", hash);
            Helper.AssertTemplateResult("", "{{ ary | map:'prop_disallowed' | join:'' }}", hash);

            hash = Hash.FromAnonymousObject(new
            {
                ary = new[] {
                    new Helper.DataObjectDrop {
                        Prop = "a"
                    },
                    new Helper.DataObjectDrop {
                        Prop = "b"
                    },
                    new Helper.DataObjectDrop {
                        Prop = "c"
                    },
                }
            });

            Helper.AssertTemplateResult("abc", "{{ ary | map:'prop' | join:'' }}", hash);
            Helper.AssertTemplateResult("", "{{ ary | map:'no_prop' | join:'' }}", hash);
        }
Ejemplo n.º 25
0
 public void TestUniq()
 {
     CollectionAssert.AreEqual(new[] { "ants", "bugs", "bees" }, StandardFilters.Uniq(new string[] { "ants", "bugs", "bees", "bugs", "ants" }));
     CollectionAssert.AreEqual(new string[] {}, StandardFilters.Uniq(new string[] {}));
     Assert.AreEqual(null, StandardFilters.Uniq(null));
     Assert.AreEqual(new List <object> {
         5
     }, StandardFilters.Uniq(5));
 }
Ejemplo n.º 26
0
 public void TestModulo()
 {
     Helper.AssertTemplateResult("1", "{{ 3 | modulo:2 }}");
     Helper.AssertTemplateResult("7.77", "{{ 148387.77 | modulo:10 }}");
     Helper.AssertTemplateResult("5.32", "{{ 3455.32 | modulo:10 }}");
     Helper.AssertTemplateResult("3.12", "{{ 23423.12 | modulo:10 }}");
     Assert.Null(StandardFilters.Modulo(null, 3));
     Assert.Null(StandardFilters.Modulo(4, null));
 }
Ejemplo n.º 27
0
 public void TestReplaceFirst()
 {
     Assert.Null(StandardFilters.ReplaceFirst(null, "a", "b"));
     Assert.AreEqual("", StandardFilters.ReplaceFirst("", "a", "b"));
     Assert.AreEqual("a a a a", StandardFilters.ReplaceFirst("a a a a", null, "b"));
     Assert.AreEqual("a a a a", StandardFilters.ReplaceFirst("a a a a", "", "b"));
     Assert.AreEqual("b a a a", StandardFilters.ReplaceFirst("a a a a", "a", "b"));
     Helper.AssertTemplateResult("b a a a", "{{ 'a a a a' | replace_first: 'a', 'b' }}");
 }
Ejemplo n.º 28
0
        public void TestEuroCurrencyFromString(string input, string expected)
        {
#if CORE
            CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
#else
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
#endif
            Assert.AreEqual(expected, StandardFilters.Currency(input, "de-DE"));
        }
Ejemplo n.º 29
0
 public ItemsHolderBuildings() : base(AssetProvider.Buildings.Values.ToList())
 {
     StandardFilters.Add("Upgrades", new UpgradesFilter(this));
     StandardFilters.Add("Available", new BuildableFilter(this)
     {
         SelectedValue = true
     });
     StandardFilters.Add("SearchText", new SearchTextFilter(this));
 }
Ejemplo n.º 30
0
 public void TestCompact()
 {
     CollectionAssert.AreEqual(new[] { "business", "celebrities", "lifestyle", "sports", "technology" }, StandardFilters.Compact(new string[] { "business", null, "celebrities", null, null, "lifestyle", "sports", null, "technology", null }));
     CollectionAssert.AreEqual(new[] { "business", "celebrities" }, StandardFilters.Compact(new string[] { "business", "celebrities" }));
     Assert.AreEqual(new List <object> {
         5
     }, StandardFilters.Compact(5));
     CollectionAssert.AreEqual(new string[] { }, StandardFilters.Compact(new string[] { }));
     Assert.AreEqual(null, StandardFilters.Compact(null));
 }