public void ShouldBeEqualWhenTwoSameDefinedCssClasses()
        {
            var cssClass = new CssClass("Button")
                           .WithStyle(CssPropertyNames.Color, "green")
                           .WithStyle(CssPropertyNames.Margin, "20px")
                           .WithlStyleInPixelUnit(CssPropertyNames.PaddingLeft, 12)
                           .WithStyle(CssPropertyNames.PaddingBottom, 15, CssUnits.Em)
                           .WithStyle(CssPropertyNames.Border, NumberCssStyleValue.CreatePixelValue(5), TextCssStyleValue.CreateTextValue("dotted"))
                           .AddPseudoSelector(PseudoSelector.Hover, props => props
                                              .WithStyle(CssPropertyNames.Color, "red")
                                              .WithStyle(CssPropertyNames.Width, "20px"))
                           .AddMediaQuery("@media (min-width: 1024px)", props =>
                                          props.WithStyle(CssPropertyNames.Width, "50px"));

            var cssClass2 = new CssClass("Button")
                            .WithStyle(CssPropertyNames.Color, "green")
                            .WithStyle(CssPropertyNames.Margin, "20px")
                            .WithlStyleInPixelUnit(CssPropertyNames.PaddingLeft, 12)
                            .WithStyle(CssPropertyNames.PaddingBottom, 15, CssUnits.Em)
                            .WithStyle(CssPropertyNames.Border, NumberCssStyleValue.CreatePixelValue(5), TextCssStyleValue.CreateTextValue("dotted"))
                            .AddPseudoSelector(PseudoSelector.Hover, props => props
                                               .WithStyle(CssPropertyNames.Color, "red")
                                               .WithStyle(CssPropertyNames.Width, "20px"))
                            .AddMediaQuery("@media (min-width: 1024px)", props =>
                                           props.WithStyle(CssPropertyNames.Width, "50px"));

            Assert.True(cssClass.Equals(cssClass2));
        }
        public void ShouldReturnOneStyleWhenComplexStyleValuesHasTwoDefinitions()
        {
            var complexStyleValue = new ComplexCssStyleValue(new ICssStyleValue[] {
                NumberCssStyleValue.CreatePixelValue(10), TextCssStyleValue.CreateTextValue("dotted")
            });

            Assert.Equal("10px dotted", complexStyleValue.CssRepresentation());
        }
Exemple #3
0
        public static CssClass WithStyle(this CssClass cssClass, string styleName, int value, CssUnits unit)
        {
            var numberValue = new NumberCssStyleValue(value, unit);

            if (cssClass is ICssProperties properties)
            {
                properties.WithStyle(styleName, numberValue);
            }

            return(cssClass);
        }
        public void ShouldReturnNumberWithCorrectUnitWhenNumberCssStyleValueIsUsed(CssUnits unit)
        {
            var numberStyleValue = new NumberCssStyleValue(10, unit);

            Assert.Equal($"10{unit.Symbol}", numberStyleValue.CssRepresentation());
        }