Skip to content

Commit

Permalink
Moved unit tests for DrawableBezier to it's own class.
Browse files Browse the repository at this point in the history
  • Loading branch information
dlemstra committed Jul 21, 2024
1 parent 54da839 commit bbe4b85
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// Copyright Dirk Lemstra https://github.com/dlemstra/Magick.NET.
// Licensed under the Apache License, Version 2.0.

using System;
using System.Linq;
using ImageMagick;
using Xunit;

namespace Magick.NET.Tests;

public partial class DrawableBezierTests
{
public class TheConstructor
{
[Fact]
public void ShouldSetPathsToEmptyCollection()
{
PointD[] coordinates = [new PointD(0, 0), new PointD(50, 50), new PointD(99, 99)];

var bezier = new DrawableBezier(coordinates.ToList());
Assert.Equal(3, bezier.Coordinates.Count);
}

[Fact]
public void ShouldThrowExceptionWhenCoordinatesAreNotSpecified()
{
Assert.Throws<ArgumentException>("coordinates", () =>
{
new DrawableBezier();
});
}

[Fact]
public void ShouldThrowExceptionWhenCoordinatesAreNull()
{
Assert.Throws<ArgumentNullException>("coordinates", () =>
{
new DrawableBezier(null);
});
}

[Fact]
public void ShouldThrowExceptionWhenCoordinatesAreEmpty()
{
Assert.Throws<ArgumentException>("coordinates", () =>
{
new DrawableBezier([]);
});
}
}
}
19 changes: 0 additions & 19 deletions tests/Magick.NET.Tests/Drawing/DrawableTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ public void Test_Drawables()
image.Draw(new DrawableAlpha(0, 0, PaintMethod.Floodfill));
image.Draw(new DrawableArc(0, 0, 10, 10, 45, 90));

var bezier = new DrawableBezier(coordinates.ToList());
Assert.Equal(3, bezier.Coordinates.Count());
image.Draw(bezier);

image.Draw(new DrawableBorderColor(MagickColors.Fuchsia));
image.Draw(new DrawableCircle(0, 0, 50, 50));
image.Draw(new DrawableClipPath("foo"));
Expand Down Expand Up @@ -178,21 +174,6 @@ public void Test_Drawables_Draw()
[Fact]
public void Test_Drawables_Exceptions()
{
Assert.Throws<ArgumentException>("coordinates", () =>
{
new DrawableBezier();
});

Assert.Throws<ArgumentNullException>("coordinates", () =>
{
new DrawableBezier(null);
});

Assert.Throws<ArgumentException>("coordinates", () =>
{
new DrawableBezier(Array.Empty<PointD>());
});

Assert.Throws<ArgumentNullException>("clipPath", () =>
{
new DrawableClipPath(null);
Expand Down

0 comments on commit bbe4b85

Please sign in to comment.