public void Background_LinearGradientBrushTest() { var style = new StyleDefn(); style.Background.ImageSource = "linear-gradient(red, green)"; var target = style.CreateBackgroundBrush(); Assert.IsNotNull(target); Assert.IsInstanceOfType(target, typeof(PDFGradientLinearBrush)); PDFGradientLinearBrush gradient = (PDFGradientLinearBrush)target; Assert.AreEqual(2, gradient.Colors.Length); Assert.AreEqual(false, gradient.Repeating); Assert.AreEqual(FillType.Pattern, gradient.FillStyle); style = new StyleDefn(); style.Background.ImageSource = "repeating-linear-gradient(red 10%, green 15%, yellow 25%)"; target = style.CreateBackgroundBrush(); Assert.IsNotNull(target); Assert.IsInstanceOfType(target, typeof(PDFGradientLinearBrush)); gradient = (PDFGradientLinearBrush)target; Assert.AreEqual(3, gradient.Colors.Length); Assert.AreEqual(true, gradient.Repeating); Assert.AreEqual(FillType.Pattern, gradient.FillStyle); }
public void PDFLinearBrushConstructor_Test() { PDFGradientLinearDescriptor descriptor = new PDFGradientLinearDescriptor(); descriptor.Colors = new List <PDFGradientColor>(new PDFGradientColor[] { new PDFGradientColor(PDFColors.Red, null, null) }); PDFGradientLinearBrush target = new PDFGradientLinearBrush(descriptor); PDFColor color = PDFColors.Red; double? opacity = null; double? distance = null; Assert.IsNotNull(target); Assert.AreEqual(GradientType.Linear, target.GradientType); Assert.AreEqual(color, target.Colors[0].Color); Assert.AreEqual(opacity, target.Colors[0].Opacity); Assert.AreEqual(distance, target.Colors[0].Distance); }