public void ThrowsExceptionForIncompletePolygon() { var empty = new Polygon(new List <Vertex>()); var onePoint = new Polygon(new[] { new Vertex(0, 0) }); var twoPoints = new Polygon(new[] { new Vertex(0, 0), new Vertex(1, 1) }); Assert.That(() => Polylabel.ComputeLabelPosition(empty), Throws.TypeOf(typeof(ArgumentOutOfRangeException))); Assert.That(() => Polylabel.ComputeLabelPosition(onePoint), Throws.TypeOf(typeof(ArgumentOutOfRangeException))); Assert.That(() => Polylabel.ComputeLabelPosition(twoPoints), Throws.TypeOf(typeof(ArgumentOutOfRangeException))); }
public void IsCorrectForTriangle() { var triangle = new Polygon(new Vertex[] { new Vertex(0, 0), new Vertex(100, 0), new Vertex(50, 100) }); Vertex result = Polylabel.ComputeLabelPosition(triangle); Assert.That(result.X, Is.EqualTo(50).Within(1E-6), "Polylabel for triangle failed: {0}", nameof(result.X)); Assert.That(result.Y, Is.EqualTo(30.901700).Within(1E-6), "Polylabel for triangle failed: {0}", nameof(result.Y)); }