Beispiel #1
0
        public void VariableTest3()
        {
            var dic = new Dictionary <string, CssValue>
            {
                ["monster"] = CssValue.Parse("red")
            };

            var sheet = StyleSheet.Parse(
                @"
$blue: #dceef7;
$yellow: #fff5cc;

body { 
  background-color: $blue;
  color: $yellow;
  monster: $monster;
}");

            Assert.Equal(
                @"body {
  background-color: #dceef7;
  color: #fff5cc;
  monster: red;
}", sheet.ToString(dic));
        }
Beispiel #2
0
        public void ValueList()
        {
            var value = CssValue.Parse("100px 100px 100px 100px") as CssValueList;

            Assert.Equal(4, value.Count);
            Assert.Equal("100px 100px 100px 100px", value.ToString());
        }
Beispiel #3
0
        public void VariableTest4()
        {
            var dic = new Dictionary <string, CssValue>
            {
                ["monster"] = CssValue.Parse("purple")
            };

            var sheet = StyleSheet.Parse(@"

$blue: #dceef7;
$yellow: #fff5cc;
$padding: 10px;
$padding-right: 20px;
body { 
  background-color: $blue;
  color: $yellow;
  monster: $monster;
  padding: $padding $padding-right $padding $padding;
}

");

            Assert.Equal(@"

body {
  background-color: #dceef7;
  color: #fff5cc;
  monster: purple;
  padding: 10px 20px 10px 10px;
}

".Trim(), sheet.ToString(dic));
        }
Beispiel #4
0
        public void ParseValues()
        {
            var(value, unit) = CssValue.Parse("14px") as CssUnitValue;

            Assert.Equal(14f, value);
            Assert.Equal("px", unit.Name);
        }
Beispiel #5
0
        public void ColorTests()
        {
            Assert.Equal("red", CssValue.Parse("red").ToString());

            var value = StyleSheet.Parse(@"body { background-color: rgba(#ffffff, 0.5) }");

            Assert.Equal("body { background-color: rgba(255, 255, 255, 0.5); }", value.ToString());
        }
Beispiel #6
0
        public void ComponentValues()
        {
            Assert.Equal("red", CssValue.Parse("red").ToString());

            var value  = CssValue.Parse("3px 3px rgba(50%, 50%, 50%, 50%), lemonchiffon 0 0 4px inset");
            var value2 = CssValue.Parse(@"""Gill Sans"", Futura, sans-serif");

            Assert.Equal("3px 3px rgba(50%, 50%, 50%, 50%), lemonchiffon 0 0 4px inset", value.ToString());
            Assert.Equal(@"""Gill Sans"", Futura, sans-serif", value2.ToString());
        }
Beispiel #7
0
        public void C()
        {
            var dic = new Dictionary <string, CssValue>
            {
                ["columnCount"] = CssValue.Parse("5"),
                ["columnWidth"] = CssUnitValue.Number(100 / 5d),
                ["gap"]         = CssValue.Parse("10px")
            };

            var sheet = StyleSheet.Parse(@"

@for $i from 1 through $columnCount { 
  .col-#{$i} { 
    left: #{$columnWidth * $i}%;
    margin: $gap * 0.5; 
  }
}

");

            Assert.Equal(@"
.col-1 {
  left: 20%;
  margin: 5px;
}
.col-2 {
  left: 40%;
  margin: 5px;
}
.col-3 {
  left: 60%;
  margin: 5px;
}
.col-4 {
  left: 80%;
  margin: 5px;
}
.col-5 {
  left: 100%;
  margin: 5px;
}

".Trim(), sheet.ToString(dic));
        }
Beispiel #8
0
        public void DefinedTests()
        {
            var dic = new Dictionary <string, CssValue>
            {
                ["monster"] = CssValue.Parse("purple")
            };

            // variable-exists
            var sheet = StyleSheet.Parse(
                @"@if $monster != undefined {
    body { 
      background-color: red;
    }
}");

            Assert.Equal(@"body { background-color: red; }", sheet.ToString(dic));

            sheet = StyleSheet.Parse(
                @"@if $monster == undefined {
    body { 
      background-color: red;
    }
}");

            Assert.Equal("", sheet.ToString(dic));



            sheet = StyleSheet.Parse(@"

@if $bananas == undefined {
    body { 
      background-color: red;
    }
}

");

            Assert.Equal(@"body { background-color: red; }", sheet.ToString(dic));
        }
Beispiel #9
0
 public void CssValueTypes()
 {
     Assert.Equal(NodeKind.Number, CssValue.Parse("123").Kind);
     Assert.Equal(NodeKind.Number, CssValue.Parse("-123").Kind);
     Assert.Equal(NodeKind.Number, CssValue.Parse("123.5").Kind);
 }
Beispiel #10
0
        public void ParseValues()
        {
            var value = CssValue.Parse("14px");

            Assert.Equal("14px", value.ToString());
        }
Beispiel #11
0
        public void NumbersAreStoredAtDoublePrecision()
        {
            var value = CssValue.Parse("97.916666666666666666666666666667%") as CssUnitValue;

            Assert.Equal(97.916666666666666666666666666667d, value.Value);
        }
Beispiel #12
0
 public void Percent()
 {
     Assert.Equal("50%", CssValue.Parse("50%").ToString());
 }
Beispiel #13
0
 public void Px()
 {
     Assert.Equal("50px", CssValue.Parse("50px").ToString());
 }
Beispiel #14
0
 public void A()
 {
     Assert.Equal("left", CssValue.Parse("left").ToString());
 }