public void Constructor_CounterClockwise_Throws() { { // Square var p = new PolygonGrid2DBuilder() .AddPoint(3, 0) .AddPoint(3, 3) .AddPoint(0, 3) .AddPoint(0, 0); Assert.Throws <ArgumentException>(() => p.Build()); } { // L Shape var p = new PolygonGrid2DBuilder() .AddPoint(6, 0) .AddPoint(6, 3) .AddPoint(3, 3) .AddPoint(3, 6) .AddPoint(0, 6) .AddPoint(0, 0); Assert.Throws <ArgumentException>(() => p.Build()); } }
public void Constructor_EdgesNotOrthogonal_Trows() { var polygon1 = new PolygonGrid2DBuilder() .AddPoint(0, 0) .AddPoint(0, 5) .AddPoint(3, 4) .AddPoint(4, 0); Assert.Throws <ArgumentException>(() => polygon1.Build()); }
public void Constructor_OverlappingEdges_Throws() { var polygon1 = new PolygonGrid2DBuilder() .AddPoint(0, 0) .AddPoint(3, 0) .AddPoint(3, 2) .AddPoint(0, 2) .AddPoint(0, 4); Assert.Throws <ArgumentException>(() => polygon1.Build()); }
public void Constructor_TooFewPoints_Throws() { var polygon1 = new PolygonGrid2DBuilder() .AddPoint(0, 0) .AddPoint(0, 5); var polygon2 = new PolygonGrid2DBuilder() .AddPoint(0, 0) .AddPoint(0, 5) .AddPoint(5, 5); Assert.Throws <ArgumentException>(() => polygon1.Build()); Assert.Throws <ArgumentException>(() => polygon2.Build()); }
public void Constructor_ValidPolygons() { var square = new PolygonGrid2DBuilder() .AddPoint(0, 0) .AddPoint(0, 3) .AddPoint(3, 3) .AddPoint(3, 0); var lPolygon = new PolygonGrid2DBuilder() .AddPoint(0, 0) .AddPoint(0, 6) .AddPoint(3, 6) .AddPoint(3, 3) .AddPoint(6, 3) .AddPoint(6, 0); Assert.DoesNotThrow(() => square.Build()); Assert.DoesNotThrow(() => lPolygon.Build()); }