Skip to content

Commit d7049c5

Browse files
committed
Added tests for the new properties. Also modified the sample program to use the new GenerateOutline extension.
1 parent 60cf9a4 commit d7049c5

7 files changed

Lines changed: 157 additions & 1 deletion

File tree

samples/DrawShapesWithImageSharp/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ private static void OutputStarOutlineDashed(int points, float inner = 10, float
199199
float offset = outer + 10;
200200

201201
var star = new Star(offset, offset, points, inner, outer);
202-
IPath outline = star.GenerateOutline(width, new float[] { 3, 3 }, false, jointStyle, cap);
202+
IPath outline = star.GenerateOutline(width, new float[] { 3, 3 }, jointStyle, cap);
203203
outline.SaveImage("Stars", $"StarOutlineDashed_{points}_{jointStyle}_{cap}.png");
204204
}
205205

tests/ImageSharp.Drawing.Tests/Drawing/Paths/DrawBezier.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,31 @@ public void ColorAndThicknessDefaultOptions()
108108
Assert.Equal(Color.Red, brush.Color);
109109
Assert.Equal(10, processor.Pen.StrokeWidth);
110110
}
111+
112+
[Fact]
113+
public void JointAndEndCapStyle()
114+
{
115+
this.operations.DrawBeziers(new DrawingOptions(), this.pen.StrokeFill, 10, this.points);
116+
117+
DrawPathProcessor processor = this.Verify<DrawPathProcessor>();
118+
119+
Assert.NotEqual(this.shapeOptions, processor.Options.ShapeOptions);
120+
this.VerifyPoints(this.points, processor.Path);
121+
Assert.Equal(this.pen.JointStyle, processor.Pen.JointStyle);
122+
Assert.Equal(this.pen.EndCap, processor.Pen.EndCap);
123+
}
124+
125+
[Fact]
126+
public void JointAndEndCapStyleDefaultOptions()
127+
{
128+
this.operations.DrawBeziers(this.pen.StrokeFill, 10, this.points);
129+
130+
DrawPathProcessor processor = this.Verify<DrawPathProcessor>();
131+
132+
Assert.Equal(this.shapeOptions, processor.Options.ShapeOptions);
133+
this.VerifyPoints(this.points, processor.Path);
134+
Assert.Equal(this.pen.JointStyle, processor.Pen.JointStyle);
135+
Assert.Equal(this.pen.EndCap, processor.Pen.EndCap);
136+
}
111137
}
112138
}

tests/ImageSharp.Drawing.Tests/Drawing/Paths/DrawLine.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,31 @@ public void ColorAndThicknessDefaultOptions()
103103
Assert.Equal(Color.Red, brush.Color);
104104
Assert.Equal(10, processor.Pen.StrokeWidth);
105105
}
106+
107+
[Fact]
108+
public void JointAndEndCapStyle()
109+
{
110+
this.operations.DrawLines(new DrawingOptions(), this.pen, this.points);
111+
112+
DrawPathProcessor processor = this.Verify<DrawPathProcessor>();
113+
114+
Assert.NotEqual(this.shapeOptions, processor.Options.ShapeOptions);
115+
this.VerifyPoints(this.points, processor.Path);
116+
Assert.Equal(this.pen.JointStyle, processor.Pen.JointStyle);
117+
Assert.Equal(this.pen.EndCap, processor.Pen.EndCap);
118+
}
119+
120+
[Fact]
121+
public void JointAndEndCapStyleDefaultOptions()
122+
{
123+
this.operations.DrawLines(this.pen, this.points);
124+
125+
DrawPathProcessor processor = this.Verify<DrawPathProcessor>();
126+
127+
Assert.Equal(this.shapeOptions, processor.Options.ShapeOptions);
128+
this.VerifyPoints(this.points, processor.Path);
129+
Assert.Equal(this.pen.JointStyle, processor.Pen.JointStyle);
130+
Assert.Equal(this.pen.EndCap, processor.Pen.EndCap);
131+
}
106132
}
107133
}

tests/ImageSharp.Drawing.Tests/Drawing/Paths/DrawPath.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,5 +90,31 @@ public void ColorAndThicknessDefaultOptions()
9090
Assert.Equal(Color.Red, brush.Color);
9191
Assert.Equal(10, processor.Pen.StrokeWidth);
9292
}
93+
94+
[Fact]
95+
public void JointAndEndCapStyle()
96+
{
97+
this.operations.Draw(new DrawingOptions(), this.pen.StrokeFill, 10, this.path);
98+
99+
DrawPathProcessor processor = this.Verify<DrawPathProcessor>();
100+
101+
Assert.NotEqual(this.shapeOptions, processor.Options.ShapeOptions);
102+
Assert.Equal(this.path, processor.Path);
103+
Assert.Equal(this.pen.JointStyle, processor.Pen.JointStyle);
104+
Assert.Equal(this.pen.EndCap, processor.Pen.EndCap);
105+
}
106+
107+
[Fact]
108+
public void JointAndEndCapStyleDefaultOptions()
109+
{
110+
this.operations.Draw(this.pen.StrokeFill, 10, this.path);
111+
112+
DrawPathProcessor processor = this.Verify<DrawPathProcessor>();
113+
114+
Assert.Equal(this.shapeOptions, processor.Options.ShapeOptions);
115+
Assert.Equal(this.path, processor.Path);
116+
Assert.Equal(this.pen.JointStyle, processor.Pen.JointStyle);
117+
Assert.Equal(this.pen.EndCap, processor.Pen.EndCap);
118+
}
93119
}
94120
}

tests/ImageSharp.Drawing.Tests/Drawing/Paths/DrawPathCollection.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,43 @@ public void ColorAndThicknessDefaultOptions()
151151
p => Assert.Equal(this.path1, p.Path),
152152
p => Assert.Equal(this.path2, p.Path));
153153
}
154+
155+
[Fact]
156+
public void JointAndEndCapStyle()
157+
{
158+
this.operations.Draw(new DrawingOptions(), this.pen.StrokeFill, 10, this.pathCollection);
159+
IEnumerable<DrawPathProcessor> processors = this.VerifyAll<DrawPathProcessor>();
160+
161+
Assert.All(processors, p =>
162+
{
163+
Assert.NotEqual(this.shapeOptions, p.Options.ShapeOptions);
164+
Assert.Equal(this.pen.JointStyle, p.Pen.JointStyle);
165+
Assert.Equal(this.pen.EndCap, p.Pen.EndCap);
166+
});
167+
168+
Assert.Collection(
169+
processors,
170+
p => Assert.Equal(this.path1, p.Path),
171+
p => Assert.Equal(this.path2, p.Path));
172+
}
173+
174+
[Fact]
175+
public void JointAndEndCapStyleDefaultOptions()
176+
{
177+
this.operations.Draw(this.pen.StrokeFill, 10, this.pathCollection);
178+
IEnumerable<DrawPathProcessor> processors = this.VerifyAll<DrawPathProcessor>();
179+
180+
Assert.All(processors, p =>
181+
{
182+
Assert.Equal(this.shapeOptions, p.Options.ShapeOptions);
183+
Assert.Equal(this.pen.JointStyle, p.Pen.JointStyle);
184+
Assert.Equal(this.pen.EndCap, p.Pen.EndCap);
185+
});
186+
187+
Assert.Collection(
188+
processors,
189+
p => Assert.Equal(this.path1, p.Path),
190+
p => Assert.Equal(this.path2, p.Path));
191+
}
154192
}
155193
}

tests/ImageSharp.Drawing.Tests/Drawing/Paths/DrawPolygon.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,5 +104,31 @@ public void ColorAndThicknessDefaultOptions()
104104
Assert.Equal(Color.Red, brush.Color);
105105
Assert.Equal(10, processor.Pen.StrokeWidth);
106106
}
107+
108+
[Fact]
109+
public void JointAndEndCapStyle()
110+
{
111+
this.operations.DrawPolygon(new DrawingOptions(), this.pen.StrokeFill, 10, this.points);
112+
113+
DrawPathProcessor processor = this.Verify<DrawPathProcessor>();
114+
115+
Assert.NotEqual(this.shapeOptions, processor.Options.ShapeOptions);
116+
this.VerifyPoints(this.points, processor.Path);
117+
Assert.Equal(this.pen.JointStyle, processor.Pen.JointStyle);
118+
Assert.Equal(this.pen.EndCap, processor.Pen.EndCap);
119+
}
120+
121+
[Fact]
122+
public void JointAndEndCapStyleDefaultOptions()
123+
{
124+
this.operations.DrawPolygon(this.pen.StrokeFill, 10, this.points);
125+
126+
DrawPathProcessor processor = this.Verify<DrawPathProcessor>();
127+
128+
Assert.Equal(this.shapeOptions, processor.Options.ShapeOptions);
129+
this.VerifyPoints(this.points, processor.Path);
130+
Assert.Equal(this.pen.JointStyle, processor.Pen.JointStyle);
131+
Assert.Equal(this.pen.EndCap, processor.Pen.EndCap);
132+
}
107133
}
108134
}

tests/ImageSharp.Drawing.Tests/Drawing/Paths/DrawRectangle.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,19 @@ public void ColorAndThicknessDefaultOptions()
9797
Assert.Equal(Color.Red, brush.Color);
9898
Assert.Equal(10, processor.Pen.StrokeWidth);
9999
}
100+
101+
[Fact]
102+
public void JointAndEndCapStyle()
103+
{
104+
this.operations.Draw(new DrawingOptions(), this.pen.StrokeFill, 10, this.rectangle);
105+
106+
DrawPathProcessor processor = this.Verify<DrawPathProcessor>();
107+
108+
Assert.NotEqual(this.shapeOptions, processor.Options.ShapeOptions);
109+
Assert.True(RectangularPolygonValueComparer.Equals(this.RectanglePolygon, processor.Path));
110+
Assert.NotEqual(this.pen, processor.Pen);
111+
Assert.Equal(this.pen.JointStyle, processor.Pen.JointStyle);
112+
Assert.Equal(this.pen.EndCap, processor.Pen.EndCap);
113+
}
100114
}
101115
}

0 commit comments

Comments
 (0)