public void BackgroundImageLinearGradientWithSide() { var source = "background-image: linear-gradient(to right, red, orange, yellow, green, blue, indigo, violet)"; var property = ParseDeclaration(source); Assert.IsTrue(property.HasValue); Assert.IsFalse(property.IsInitial); var value = property.RawValue as CssListValue; Assert.IsNotNull(value); Assert.AreEqual(1, value.Items.Length); var gradient = value.Items[0] as CssLinearGradientValue; Assert.IsFalse(gradient.IsRepeating); Assert.AreEqual(Angle.Quarter, gradient.Angle); var stops = gradient.Stops.ToArray(); Assert.AreEqual(7, stops.Length); Assert.AreEqual(CssColors.GetColor("red").Value, stops[0].Color); Assert.AreEqual(CssColors.GetColor("orange").Value, stops[1].Color); Assert.AreEqual(CssColors.GetColor("yellow").Value, stops[2].Color); Assert.AreEqual(CssColors.GetColor("green").Value, stops[3].Color); Assert.AreEqual(CssColors.GetColor("blue").Value, stops[4].Color); Assert.AreEqual(CssColors.GetColor("indigo").Value, stops[5].Color); Assert.AreEqual(CssColors.GetColor("violet").Value, stops[6].Color); }
public void BackgroundImageLinearGradientNoAngle() { var source = "background-image: linear-gradient(yellow, blue 20%, #0f0)"; var property = ParseDeclaration(source); Assert.IsTrue(property.HasValue); Assert.IsFalse(property.IsInitial); var value = property.RawValue as CssListValue; Assert.IsNotNull(value); Assert.AreEqual(1, value.Items.Length); var gradient = value.Items[0] as CssLinearGradientValue; Assert.IsFalse(gradient.IsRepeating); Assert.AreEqual(Angle.Half, gradient.Angle); Assert.AreEqual(3, gradient.Stops.Count()); Assert.AreEqual(CssColors.GetColor("yellow").Value, gradient.Stops.First().Color); Assert.AreEqual(CssColors.GetColor("blue").Value, gradient.Stops.Skip(1).First().Color); Assert.AreEqual(Color.FromRgb(0, 255, 0), gradient.Stops.Skip(2).First().Color); }