public void MergeIntoTest() { Scryber.Components.Label lbl = new Scryber.Components.Label(); lbl.StyleClass = "myclass"; lbl.ID = "myId"; StyleDefn target = new StyleDefn(); target.Background.Color = Scryber.Drawing.PDFColors.Aqua; Style style = new Style(); style.Background.Color = Scryber.Drawing.PDFColors.Blue; //matched should have aqua applied, non-matching should stay blue //match applied type target.AppliedType = typeof(Scryber.Components.Label); target.MergeInto(style, lbl, ComponentState.Normal); style.Flatten(); Assert.AreEqual(Scryber.Drawing.PDFColors.Aqua, style.Background.Color); //non-matching applied type target.AppliedType = typeof(Scryber.Components.TableCell); style = new Style(); style.Background.Color = Scryber.Drawing.PDFColors.Blue; target.MergeInto(style, lbl, ComponentState.Normal); Assert.AreEqual(Scryber.Drawing.PDFColors.Blue, style.Background.Color); }
public void MergeIntoTest() { StyleDefn target = CreatePDFStyleBase(); StyleDefn style = CreateAlternateStyle(); // // label with matching class name - should be merged // Scryber.Components.Label lbl = new Components.Label(); lbl.StyleClass = "sea"; lbl.ID = "mylabel"; ComponentState state = ComponentState.Down; target.MergeInto(style, lbl, state); style.Flatten(); //must flatten the style after a merge Assert.AreEqual(style.Padding.All, (Scryber.Drawing.PDFUnit) 10); // part of style Assert.AreEqual(style.Background.Color, Scryber.Drawing.PDFColors.Aqua); // should have been replaced by targets color Assert.AreEqual(style.Background.FillStyle, Scryber.Drawing.FillType.Pattern); //from the target - not replaced by the change of color Assert.IsTrue(style.IsValueDefined(StyleKeys.BorderColorKey)); Assert.AreEqual(style.Border.Width, (Scryber.Drawing.PDFUnit) 4); //from the target - not originally in style Assert.AreEqual(style.Border.Color, Scryber.Drawing.PDFColors.Blue); //from the target - not originally in style //No style class so should not be merged. target = CreatePDFStyleBase(); style = CreateAlternateStyle(); lbl = new Components.Label(); lbl.ID = "mylabel"; target.MergeInto(style, lbl, state); Assert.AreEqual(style.Padding.All, (Scryber.Drawing.PDFUnit) 10); Assert.AreEqual(style.Background.Color, Scryber.Drawing.PDFColors.Yellow); Assert.AreEqual(style.Background.FillStyle, Scryber.Drawing.FillType.Pattern); Assert.IsFalse(style.IsValueDefined(StyleKeys.BorderColorKey)); //Different ID so should not be merged. target = CreatePDFStyleBase(); style = CreateAlternateStyle(); lbl = new Components.Label(); lbl.StyleClass = "sea"; lbl.ID = "anotherlabel"; target.MergeInto(style, lbl, state); Assert.AreEqual(style.Padding.All, (Scryber.Drawing.PDFUnit) 10); Assert.AreEqual(style.Background.Color, Scryber.Drawing.PDFColors.Yellow); Assert.AreEqual(style.Background.FillStyle, Scryber.Drawing.FillType.Pattern); Assert.IsFalse(style.IsValueDefined(StyleKeys.BorderColorKey)); // different type Components.Image img = new Components.Image(); img.StyleClass = "sea"; img.ID = "mylabel"; target.MergeInto(style, img, state); Assert.AreEqual(style.Padding.All, (Scryber.Drawing.PDFUnit) 10); Assert.AreEqual(style.Background.Color, Scryber.Drawing.PDFColors.Yellow); Assert.AreEqual(style.Background.FillStyle, Scryber.Drawing.FillType.Pattern); Assert.IsFalse(style.IsValueDefined(StyleKeys.BorderColorKey)); }