diff --git a/src/ExCSS.Tests/PropertyTests/OpacityPropertyTests.cs b/src/ExCSS.Tests/PropertyTests/OpacityPropertyTests.cs index 5b1c475..9adc445 100644 --- a/src/ExCSS.Tests/PropertyTests/OpacityPropertyTests.cs +++ b/src/ExCSS.Tests/PropertyTests/OpacityPropertyTests.cs @@ -11,9 +11,30 @@ public void OpacityPercentLegal() Assert.Equal("opacity", property.Name); Assert.False(property.IsImportant); Assert.IsType(property); - var concrete = (OpacityProperty)property; - Assert.False(concrete.IsInherited); - Assert.True(concrete.HasValue); - Assert.Equal("50%", concrete.Value); + var result = (OpacityProperty)property; + Assert.False(result.IsInherited); + Assert.True(result.HasValue); + Assert.Equal("50%", result.Value); + } + + + [Fact] + public void OpacityVarianceTests() + { + var property = ParseDeclaration("opacity: 50%"); + var result = (OpacityProperty)property; + Assert.Equal("50%", result.Value); + + property = ParseDeclaration("opacity: .50"); + result = (OpacityProperty)property; + Assert.Equal("50%", result.Value); + + property = ParseDeclaration("opacity: 1"); + result = (OpacityProperty)property; + Assert.Equal("100%", result.Value); + + property = ParseDeclaration("opacity: 0"); + result = (OpacityProperty)property; + Assert.Equal("0%", result.Value); } } diff --git a/src/ExCSS/Extensions/ValueExtensions.cs b/src/ExCSS/Extensions/ValueExtensions.cs index 6f20555..43cdddb 100644 --- a/src/ExCSS/Extensions/ValueExtensions.cs +++ b/src/ExCSS/Extensions/ValueExtensions.cs @@ -111,7 +111,7 @@ public static Length ToLength(this FontSize fontSize) try { var number = token.Value; - var percentage = number / 100; + var percentage = number * 100; return new Percent(percentage); } catch