public void Padding_TryGetThicknessTest() { PaddingStyle target = new PaddingStyle(); PDFThickness actual; PDFThickness expected = PDFThickness.Empty(); bool result = target.TryGetThickness(out actual); Assert.IsFalse(result); Assert.AreEqual(expected, actual); target.All = 12; expected = new PDFThickness(12); result = target.TryGetThickness(out actual); Assert.IsTrue(result); Assert.AreEqual(expected, actual); target.Left = 13; target.Right = 14; target.Top = 15; target.Bottom = 16; expected = new PDFThickness(15, 14, 16, 13); result = target.TryGetThickness(out actual); Assert.IsTrue(result); Assert.AreEqual(expected, actual); target.RemoveAllValues(); expected = PDFThickness.Empty(); result = target.TryGetThickness(out actual); Assert.IsFalse(result); Assert.AreEqual(expected, actual); }
public void Empty_Test() { PDFThickness expected = new PDFThickness(0, 0, 0, 0); PDFThickness actual; actual = PDFThickness.Empty(); Assert.AreEqual(expected, actual); }
protected override void DoSetNativeValue(object value, IPDFComponent owner) { if (null == value) { this.Value = PDFThickness.Empty(); } else { this.Value = (PDFThickness)value; } }
protected override void DoSetNativeValueFromString(string value, IPDFComponent owner) { PDFThickness val; if (PDFThickness.TryParse(value, out val)) { this.Value = val; } else { this.Value = PDFThickness.Empty(); } }
public void CreatePostionOptionsTest() { Style target = new Style(); //Default (empty) position options PDFPositionOptions actual = target.CreatePostionOptions(); Assert.AreEqual(false, actual.FillWidth); Assert.AreEqual(HorizontalAlignment.Left, actual.HAlign); Assert.AreEqual(false, actual.Height.HasValue); Assert.AreEqual(false, actual.Width.HasValue); Assert.AreEqual(false, actual.X.HasValue); Assert.AreEqual(false, actual.Y.HasValue); Assert.AreEqual(PDFThickness.Empty(), actual.Margins); Assert.AreEqual(OverflowAction.NewPage, actual.OverflowAction); Assert.AreEqual(OverflowSplit.Any, actual.OverflowSplit); Assert.AreEqual(PDFThickness.Empty(), actual.Padding); Assert.AreEqual(PositionMode.Block, actual.PositionMode); Assert.AreEqual(VerticalAlignment.Top, actual.VAlign); Assert.AreEqual(Visibility.Visible, actual.Visibility); Assert.AreEqual(null, actual.Height); Assert.AreEqual(null, actual.Width); Assert.AreEqual(null, actual.X); Assert.AreEqual(null, actual.Y); Assert.AreEqual(false, actual.MinimumHeight.HasValue); Assert.AreEqual(false, actual.MinimumWidth.HasValue); Assert.AreEqual(false, actual.MaximumHeight.HasValue); Assert.AreEqual(false, actual.MaximumWidth.HasValue); Assert.AreEqual(null, actual.MinimumHeight); Assert.AreEqual(null, actual.MinimumWidth); Assert.AreEqual(null, actual.MaximumHeight); Assert.AreEqual(null, actual.MaximumWidth); target = new Style(); target.Position.PositionMode = PositionMode.Inline; target.Size.FullWidth = true; target.Position.HAlign = HorizontalAlignment.Center; target.Position.VAlign = VerticalAlignment.Middle; target.Position.X = 20; target.Position.Y = 50; target.Size.Width = 100; //Don't define height target.Size.MaximumHeight = 90; target.Size.MinimumHeight = 50; target.Size.MaximumWidth = 200; target.Size.MinimumWidth = 150; target.Overflow.Action = OverflowAction.Truncate; target.Overflow.Split = OverflowSplit.Never; target.Margins.All = 10; target.Margins.Bottom = 20; target.Padding.All = 20; target.Padding.Right = 40; actual = target.CreatePostionOptions(); Assert.AreEqual(false, actual.FillWidth); //false because a width has been set Assert.AreEqual(HorizontalAlignment.Center, actual.HAlign); Assert.AreEqual(VerticalAlignment.Middle, actual.VAlign); Assert.AreEqual(false, actual.Height.HasValue); Assert.AreEqual(true, actual.Width.HasValue); Assert.AreEqual(true, actual.X.HasValue); Assert.AreEqual(true, actual.Y.HasValue); Assert.AreEqual((PDFUnit)100, actual.Width); Assert.AreEqual((PDFUnit)20, actual.X); Assert.AreEqual((PDFUnit)50, actual.Y); Assert.AreEqual(null, actual.Height); Assert.AreEqual((PDFUnit)200, actual.MaximumWidth); Assert.AreEqual((PDFUnit)150, actual.MinimumWidth); Assert.AreEqual((PDFUnit)90, actual.MaximumHeight); Assert.AreEqual((PDFUnit)50, actual.MinimumHeight); Assert.AreEqual(OverflowAction.Truncate, actual.OverflowAction); Assert.AreEqual(OverflowSplit.Never, actual.OverflowSplit); Assert.AreEqual((PDFUnit)10, actual.Margins.Left); Assert.AreEqual((PDFUnit)20, actual.Margins.Bottom); Assert.AreEqual((PDFUnit)20, actual.Padding.Left); Assert.AreEqual((PDFUnit)40, actual.Padding.Right); Assert.AreEqual(PositionMode.Relative, actual.PositionMode); //mode is relative (because we have an xand a y) Assert.AreEqual(VerticalAlignment.Middle, actual.VAlign); Assert.AreEqual(Visibility.Visible, actual.Visibility); }
public ThicknessItemValue() : base(typeof(PDFColor)) { this.Value = PDFThickness.Empty(); }