Compare commits
2 Commits
shared-images
...
2021.04
| Author | SHA1 | Date | |
|---|---|---|---|
| 9f927ec402 | |||
| 9dc3e2b533 |
@@ -14,20 +14,7 @@ namespace QuestPDF.UnitTests
|
||||
|
||||
[Test]
|
||||
public void Draw_ShouldHandleNullChild() => new Alignment().DrawWithoutChild();
|
||||
|
||||
[Test]
|
||||
public void Measure_ShouldReturnWrap_WhenChildReturnsWrap()
|
||||
{
|
||||
TestPlan
|
||||
.For(x => new Alignment
|
||||
{
|
||||
Child = x.CreateChild()
|
||||
})
|
||||
.MeasureElement(new Size(1000, 500))
|
||||
.ExpectChildMeasure(expectedInput: new Size(1000, 500), returns: new Wrap())
|
||||
.CheckMeasureResult(new Wrap());
|
||||
}
|
||||
|
||||
|
||||
[Test]
|
||||
public void Draw_HorizontalCenter_VerticalCenter()
|
||||
{
|
||||
|
||||
@@ -15,14 +15,29 @@ namespace QuestPDF.UnitTests
|
||||
[Test]
|
||||
public void Draw_ShouldHandleNullChild() => new Constrained().DrawWithoutChild();
|
||||
|
||||
#region Min Height
|
||||
|
||||
[Test]
|
||||
public void Measure_MinHeight_ExpectWrap()
|
||||
public void Measure_MinHeight_Empty()
|
||||
{
|
||||
TestPlan
|
||||
.For(x => new Constrained
|
||||
{
|
||||
MinHeight = 100
|
||||
})
|
||||
.MeasureElement(new Size(400, 150))
|
||||
.CheckMeasureResult(new FullRender(0, 100));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Measure_MinHeight_NotEnoughHeight()
|
||||
{
|
||||
TestPlan
|
||||
.For(x => new Constrained
|
||||
{
|
||||
MinHeight = 100,
|
||||
Child = x.CreateChild()
|
||||
})
|
||||
.MeasureElement(new Size(400, 50))
|
||||
.CheckMeasureResult(new Wrap());
|
||||
}
|
||||
@@ -55,6 +70,10 @@ namespace QuestPDF.UnitTests
|
||||
.CheckMeasureResult(new FullRender(400, 150));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Max Height
|
||||
|
||||
[Test]
|
||||
public void Measure_MaxHeight_Empty()
|
||||
{
|
||||
@@ -68,7 +87,7 @@ namespace QuestPDF.UnitTests
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Measure_MaxHeight_PartialRender()
|
||||
public void Measure_MaxHeight_PassHeight()
|
||||
{
|
||||
TestPlan
|
||||
.For(x => new Constrained
|
||||
@@ -77,22 +96,174 @@ namespace QuestPDF.UnitTests
|
||||
Child = x.CreateChild()
|
||||
})
|
||||
.MeasureElement(new Size(400, 200))
|
||||
.ExpectChildMeasure(new Size(400, 100), new PartialRender(400, 75))
|
||||
.CheckMeasureResult(new PartialRender(400, 75));
|
||||
.ExpectChildMeasure(new Size(400, 100), new FullRender(400, 75))
|
||||
.CheckMeasureResult(new FullRender(400, 75));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Min Width
|
||||
|
||||
[Test]
|
||||
public void Measure_MinWidth_Empty()
|
||||
{
|
||||
TestPlan
|
||||
.For(x => new Constrained
|
||||
{
|
||||
MinWidth = 100
|
||||
})
|
||||
.MeasureElement(new Size(150, 400))
|
||||
.CheckMeasureResult(new FullRender(100, 0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Measure_MaxHeight_ExpectWrap()
|
||||
public void Measure_MinWidth_NotEnoughWidth()
|
||||
{
|
||||
TestPlan
|
||||
.For(x => new Constrained
|
||||
{
|
||||
MaxHeight = 100,
|
||||
MinWidth = 100,
|
||||
Child = x.CreateChild()
|
||||
})
|
||||
.MeasureElement(new Size(50, 400))
|
||||
.CheckMeasureResult(new Wrap());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Measure_MinWidth_ExtendWidth()
|
||||
{
|
||||
TestPlan
|
||||
.For(x => new Constrained
|
||||
{
|
||||
MinWidth = 100,
|
||||
Child = x.CreateChild()
|
||||
})
|
||||
.MeasureElement(new Size(400, 200))
|
||||
.ExpectChildMeasure(new Size(400, 100), new Wrap())
|
||||
.ExpectChildMeasure(new Size(400, 200), new FullRender(50, 200))
|
||||
.CheckMeasureResult(new FullRender(100, 200));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Measure_MinWidth_PassWidth()
|
||||
{
|
||||
TestPlan
|
||||
.For(x => new Constrained
|
||||
{
|
||||
MinWidth = 100,
|
||||
Child = x.CreateChild()
|
||||
})
|
||||
.MeasureElement(new Size(400, 200))
|
||||
.ExpectChildMeasure(new Size(400, 200), new FullRender(150, 200))
|
||||
.CheckMeasureResult(new FullRender(150, 200));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Max Width
|
||||
|
||||
[Test]
|
||||
public void Measure_MaxWidth_Empty()
|
||||
{
|
||||
TestPlan
|
||||
.For(x => new Constrained
|
||||
{
|
||||
MaxWidth = 100
|
||||
})
|
||||
.MeasureElement(new Size(400, 150))
|
||||
.CheckMeasureResult(new FullRender(0, 0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Measure_MaxWidth_PassWidth()
|
||||
{
|
||||
TestPlan
|
||||
.For(x => new Constrained
|
||||
{
|
||||
MaxWidth = 100,
|
||||
Child = x.CreateChild()
|
||||
})
|
||||
.MeasureElement(new Size(400, 200))
|
||||
.ExpectChildMeasure(new Size(100, 200), new FullRender(75, 200))
|
||||
.CheckMeasureResult(new FullRender(75, 200));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Space Plans
|
||||
|
||||
[Test]
|
||||
public void Measure_AcceptsFullRender()
|
||||
{
|
||||
TestPlan
|
||||
.For(x => new Constrained
|
||||
{
|
||||
Child = x.CreateChild()
|
||||
})
|
||||
.MeasureElement(new Size(400, 200))
|
||||
.ExpectChildMeasure(new Size(400, 200), new FullRender(300, 200))
|
||||
.CheckMeasureResult(new FullRender(300, 200));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Measure_AcceptsPartialRender()
|
||||
{
|
||||
TestPlan
|
||||
.For(x => new Constrained
|
||||
{
|
||||
Child = x.CreateChild()
|
||||
})
|
||||
.MeasureElement(new Size(400, 200))
|
||||
.ExpectChildMeasure(new Size(400, 200), new PartialRender(300, 200))
|
||||
.CheckMeasureResult(new PartialRender(300, 200));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Measure_AcceptsWrap()
|
||||
{
|
||||
TestPlan
|
||||
.For(x => new Constrained
|
||||
{
|
||||
Child = x.CreateChild()
|
||||
})
|
||||
.MeasureElement(new Size(400, 200))
|
||||
.ExpectChildMeasure(new Size(400, 200), new Wrap())
|
||||
.CheckMeasureResult(new Wrap());
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Drawing
|
||||
|
||||
[Test]
|
||||
public void Draw_Normal()
|
||||
{
|
||||
TestPlan
|
||||
.For(x => new Constrained
|
||||
{
|
||||
MaxWidth = 500,
|
||||
MaxHeight = 300,
|
||||
Child = x.CreateChild()
|
||||
})
|
||||
.DrawElement(new Size(400, 200))
|
||||
.ExpectChildDraw(new Size(400, 200))
|
||||
.CheckDrawResult();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Draw_Shrink()
|
||||
{
|
||||
TestPlan
|
||||
.For(x => new Constrained
|
||||
{
|
||||
MaxWidth = 300,
|
||||
MaxHeight = 150,
|
||||
Child = x.CreateChild()
|
||||
})
|
||||
.DrawElement(new Size(400, 200))
|
||||
.ExpectChildDraw(new Size(300, 150))
|
||||
.CheckDrawResult();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace QuestPDF.UnitTests
|
||||
{
|
||||
[TestFixture]
|
||||
public class PageableColumnTests
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -31,15 +31,15 @@ namespace QuestPDF.Elements
|
||||
if (measurement is Wrap)
|
||||
return new Wrap();
|
||||
|
||||
var actualSize = new Size(
|
||||
var targetSize = new Size(
|
||||
MathHelpers.Max(MinWidth, size.Width),
|
||||
MathHelpers.Max(MinHeight, size.Height));
|
||||
|
||||
if (size is FullRender)
|
||||
return new FullRender(actualSize);
|
||||
return new FullRender(targetSize);
|
||||
|
||||
if (size is PartialRender)
|
||||
return new PartialRender(actualSize);
|
||||
return new PartialRender(targetSize);
|
||||
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
+17
-11
@@ -4,9 +4,16 @@
|
||||
<Authors>MarcinZiabek</Authors>
|
||||
<Company>CodeFlint</Company>
|
||||
<PackageId>QuestPDF</PackageId>
|
||||
<Version>2021.3.1</Version>
|
||||
<Version>2021.4.0</Version>
|
||||
<PackageDescription>QuestPDF is an open-source, modern and battle-tested library that can help you with generating PDF documents by offering friendly, discoverable and predictable C# fluent API.</PackageDescription>
|
||||
<PackageReleaseNotes>Generating images functionality, ShowIf element, fixed mutating TextStyle</PackageReleaseNotes>
|
||||
<PackageReleaseNotes>
|
||||
1. Added new element: `Debug` - this element can be used for inspecting its children and space taken by them,
|
||||
2. Added new element: `Element` can be used for injecting dynamic elements (usually conditionally) without breaking the fluent API chain. This is practically a syntactic sugar to simplify your code.
|
||||
3. The `AspectRatio` element allows now to specify scaling rule: fitting width, height or available space.
|
||||
4. The `Image` element supports now scaling rules: fitting width, height or available space, as well as scaling unproportionally.
|
||||
5. Added more, commonly used page sizes (thank you for your work [lmingle](https://github.com/lmingle)).
|
||||
6. Bug fix: the `GeneratePdf(Stream stream)` method does not close the output stream (thank you for your suggestion [tthiery](https://github.com/tthiery)).
|
||||
</PackageReleaseNotes>
|
||||
<LangVersion>8</LangVersion>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<PackageIcon>Logo.png</PackageIcon>
|
||||
@@ -22,17 +29,16 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="SkiaSharp" Version="2.80.2" />
|
||||
<PackageReference Include="SkiaSharp" Version="2.80.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Resources\ImagePlaceholder.png" />
|
||||
<None Remove="ImagePlaceholder.png" />
|
||||
<None Include="Resources\Logo.png">
|
||||
<Pack>true</Pack>
|
||||
<Visible>false</Visible>
|
||||
<PackagePath>\</PackagePath>
|
||||
</None>
|
||||
<EmbeddedResource Include="Resources\ImagePlaceholder.png" />
|
||||
<None Remove="ImagePlaceholder.png" />
|
||||
<None Include="Resources\Logo.png">
|
||||
<Pack>true</Pack>
|
||||
<Visible>false</Visible>
|
||||
<PackagePath>\</PackagePath>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user