Exemple #1
0
        public async Task CycleShouldSupportNumbers()
        {
            var group1 = new CycleStatement(
                LIT("x"),
                new[] {
                LIT(1), LIT(2), LIT(3)
            }
                );

            var group2 = new CycleStatement(
                LIT("y"),
                new[] {
                LIT("a"), LIT("b"), LIT("c")
            }
                );

            var context = new TemplateContext();

            var sw = new StringWriter();

            for (var i = 1; i <= 5; i++)
            {
                await group1.WriteToAsync(sw, HtmlEncoder.Default, context);

                await group2.WriteToAsync(sw, HtmlEncoder.Default, context);
            }

            Assert.Equal("1a2b3c1a2b", sw.ToString());
        }
Exemple #2
0
        public async Task CycleEvaluatesGroupsValue()
        {
            var group1 = new CycleStatement(
                LIT("x"),
                new[] {
                LIT("a"), LIT("b"), LIT("c")
            }
                );

            var group2 = new CycleStatement(
                LIT("y"),
                new[] {
                LIT("a"), LIT("b"), LIT("c")
            }
                );

            var context = new TemplateContext();

            var sw = new StringWriter();

            for (var i = 1; i <= 5; i++)
            {
                await group1.WriteToAsync(sw, HtmlEncoder.Default, context);

                await group2.WriteToAsync(sw, HtmlEncoder.Default, context);
            }

            Assert.Equal("aabbccaabb", sw.ToString());
        }
Exemple #3
0
        public async Task CycleAlternateValuesList()
        {
            var group1 = new CycleStatement(
                null,
                new[] {
                LIT("a"), LIT("b"), LIT("c")
            }
                );

            var group2 = new CycleStatement(
                null,
                new[] {
                LIT("d"), LIT("e"), LIT("f")
            }
                );

            var context = new TemplateContext();

            var sw = new StringWriter();

            for (var i = 1; i <= 5; i++)
            {
                await group1.WriteToAsync(sw, HtmlEncoder.Default, context);

                await group2.WriteToAsync(sw, HtmlEncoder.Default, context);
            }

            Assert.Equal("aecdbfaecd", sw.ToString());
        }
Exemple #4
0
        public async Task CycleShouldGroupByStringRepresentation()
        {
            var group1 = new CycleStatement(
                LIT(2),
                new[] {
                LIT("a"), LIT("b"), LIT("c")
            }
                );

            var group2 = new CycleStatement(
                LIT("2"),
                new[] {
                LIT("a"), LIT("b"), LIT("c")
            }
                );

            var context = new TemplateContext();

            var sw = new StringWriter();

            for (var i = 1; i <= 5; i++)
            {
                await group1.WriteToAsync(sw, HtmlEncoder.Default, context);

                await group2.WriteToAsync(sw, HtmlEncoder.Default, context);
            }

            Assert.Equal("abcabcabca", sw.ToString());
        }
Exemple #5
0
        public async Task CycleEvaluatesEachValue()
        {
            var e = new CycleStatement(
                null,
                new[] {
                LIT("a"), LIT("b"), LIT("c")
            }
                );

            var context = new TemplateContext();

            var sw = new StringWriter();

            for (var i = 1; i <= 10; i++)
            {
                await e.WriteToAsync(sw, HtmlEncoder.Default, context);
            }

            Assert.Equal("abcabcabca", sw.ToString());
        }