public void CurrentTest() { Style root = new Style(); StyleStack target = new StyleStack(root); Assert.AreEqual(root, target.Current); Style one = new Style(); target.Push(one); Assert.AreEqual(one, target.Current); Style two = new Style(); target.Push(two); Assert.AreEqual(two, target.Current); }
public void PopTest() { Style root = new Style(); StyleStack target = new StyleStack(root); Style one = new Style(); target.Push(one); Style two = new Style(); target.Push(two); Style expected = two; Style actual; actual = target.Pop(); Assert.AreEqual(expected, actual); expected = one; actual = target.Pop(); Assert.AreEqual(expected, actual); expected = root; actual = target.Pop(); Assert.AreEqual(expected, actual); try { actual = target.Pop(); throw new ArgumentException("Stack should be empty"); } catch (InvalidOperationException) { //Successfully thrown empty stack exception } }
public void GetFullStyleTest() { Style root = new Style(); root.Background.Color = PDFColors.Red; //Not inherited root.Font.FontFamily = (PDFFontSelector)"Symbol"; //Font is inherited root.Font.FontSize = 20; //Font is inherited StyleStack target = new StyleStack(root); Style one = new Style(); one.Background.FillStyle = FillType.Pattern; //Background is not inherited one.Border.Width = 2; //Border is not inherited one.Font.FontSize = 48; //Font is inherited - override root target.Push(one); //last item will always be merged in a full style - actual, not inherited values Style two = new Style(); two.Border.Color = PDFColors.Lime; two.Border.Width = 3; two.Font.FontItalic = true; target.Push(two); Label lbl = new Label(); Style actual = target.GetFullStyle(lbl); Assert.AreEqual("Symbol", actual.Font.FontFamily.FamilyName); //inherited from root Assert.AreEqual((PDFUnit)48, actual.Font.FontSize); //inherited from one Assert.AreEqual((PDFUnit)3, actual.Border.Width); //border from two Assert.AreEqual(PDFColors.Lime, actual.Border.Color); //border from two Assert.AreEqual(true, actual.Font.FontItalic); //font from two Assert.AreEqual(PDFColor.Transparent, actual.Background.Color); //not inherited from root Assert.AreEqual(FillType.None, actual.Background.FillStyle); //not inherited from one }