예제 #1
0
        public void GetCssStylesText()
        {
            var o = new DeltaInsertOp("f", _styleAttributes);
            var c = new OpToXmlConverter(o, _styleConverterOptions);

            c.GetCssStyles().Should().BeEquivalentTo(_styleAttributesCss);
        }
예제 #2
0
        public void GetCssStylesEmpty()
        {
            var op = new DeltaInsertOp("aa");
            var c  = new OpToXmlConverter(op);

            c.GetCssStyles().Count().Should().Be(0);
        }
예제 #3
0
        public void GetCssStylesFormula()
        {
            var o = new DeltaInsertOp(new InsertDataFormula(""), _styleAttributes);
            var c = new OpToXmlConverter(o, _styleConverterOptions);

            c.GetCssStyles().Should().BeEquivalentTo(_styleAttributesCss);
        }
예제 #4
0
        public void GetCssStylesWithInlineStylesManyStyles()
        {
            var op = new DeltaInsertOp("f", _styleAttributes);
            var c  = new OpToXmlConverter(op, _styleConverterOptions);

            c.GetCssStyles().Should().BeEquivalentTo(_styleAttributesCss);
        }
예제 #5
0
        public void GetCssStylesWithInlineStylesNoStyles()
        {
            var op = new DeltaInsertOp("hello");
            var c  = new OpToXmlConverter(op, _styleConverterOptions);

            c.GetCssStyles().Should().Equal(new string[] { });
        }
예제 #6
0
        public void GetCssStylesBackgroundForeground()
        {
            var o = new DeltaInsertOp("f", new OpAttributes
            {
                Background = "red",
                Color      = "blue"
            });
            var c = new OpToXmlConverter(o);

            c.GetCssStyles().Should().Equal(new string[] { "color:blue", "background-color:red" });
        }
예제 #7
0
        public void GetCssStylesRendersDefaultFontsCorrectly()
        {
            var op = new DeltaInsertOp("f",
                                       new OpAttributes {
                Font = "monospace"
            });
            var c = new OpToXmlConverter(op, _styleConverterOptions);

            c.GetCssStyles().Should().BeEquivalentTo(new string[] {
                "font-family: Monaco, Courier New, monospace"
            });
        }
예제 #8
0
        public void GetCssStylesIndent()
        {
            var o = new DeltaInsertOp(new InsertDataImage(""),
                                      new OpAttributes {
                Indent = 2
            });
            var c = new OpToXmlConverter(o, _styleConverterOptions);

            c.GetCssStyles().Should().BeEquivalentTo(new string[] {
                "padding-left:6em"
            });
        }
예제 #9
0
        public void GetCssStylesRtl()
        {
            var o = new DeltaInsertOp(new InsertDataImage(""),
                                      new OpAttributes {
                Direction = DirectionType.Rtl
            });
            var c = new OpToXmlConverter(o, _styleConverterOptions);

            c.GetCssStyles().Should().BeEquivalentTo(new string[] {
                "direction:rtl; text-align:inherit"
            });
        }
예제 #10
0
        public void GetCssStylesAllowBackgroundClasses()
        {
            var o = new DeltaInsertOp("f", new OpAttributes
            {
                Background = "red",
                Color      = "blue"
            });
            var c = new OpToXmlConverter(o, new OpToXmlConverterOptions()
            {
                AllowBackgroundClasses = true
            });

            c.GetCssStyles().Should().Equal(new string[] { "color:blue" });
        }
예제 #11
0
        public void GetCssStylesReturnsNothingWhereConverterIsNull()
        {
            var op = new DeltaInsertOp("f",
                                       new OpAttributes {
                Size = "biggest"
            });
            var c = new OpToXmlConverter(op, new OpToXmlConverterOptions()
            {
                InlineStyles = new InlineStyles()
                {
                    Size = null
                }
            });

            c.GetCssStyles().Should().BeEquivalentTo(new string[] { });
        }
예제 #12
0
        public void GetCssStylesReturnsNothingWhereNoEntryMapped()
        {
            var op = new DeltaInsertOp("f",
                                       new OpAttributes {
                Size = "biggest"
            });
            var styleDic = new Dictionary <string, string>()
            {
                { "small", "font-size: 0.75em" }
            };
            var c = new OpToXmlConverter(op, new OpToXmlConverterOptions {
                InlineStyles = new InlineStyles()
                {
                    Size = InlineStyles.MakeLookup(styleDic)
                }
            });

            c.GetCssStyles().Should().BeEquivalentTo(new string[] { });
        }
예제 #13
0
        public void GetCssStylesCustomStyle()
        {
            var op = new DeltaInsertOp("f",
                                       new OpAttributes {
                Size = "huge"
            });
            var styleDic = new Dictionary <string, string>()
            {
                { "huge", "font-size: 6em" }
            };
            var c = new OpToXmlConverter(op, new OpToXmlConverterOptions()
            {
                InlineStyles = new InlineStyles()
                {
                    Size = (value, dop) => InlineStyles.LookupValue(styleDic, value)
                }
            });

            c.GetCssStyles().Should().BeEquivalentTo(new string[] {
                "font-size: 6em"
            });
        }
예제 #14
0
        public void GetCssStylesUsesDefaultsWhereUnspecified()
        {
            // Here there's no inlineStyle specified for "size", but we still render it
            // because we fall back to the default.
            var op = new DeltaInsertOp("f",
                                       new OpAttributes {
                Size = "huge"
            });
            var styleDic = new Dictionary <string, string>()
            {
                { "serif", "font-family: serif" }
            };
            var c = new OpToXmlConverter(op, new OpToXmlConverterOptions()
            {
                InlineStyles = new InlineStyles()
                {
                    Font = (value, dop) => InlineStyles.LookupValue(styleDic, value)
                }
            });

            c.GetCssStyles().Should().BeEquivalentTo(new string[] {
                "font-size: 2.5em"
            });
        }