public string Post([FromBody] IEnumerable <SimplePoint> points) { if (points == null) { return("Invalid Quadrilaterals"); } var shape = new Models.Quadrilateral(points.ToArray()); try { return(shape.GetShapeType()); } catch (Exception) { return("Invalid Quadrilaterals"); } }
public void GetShapeType() { var square = new Models.Quadrilateral(new LineSegment[] { new LineSegment() { Coordinates = new SimplePoint[] { new SimplePoint() { X = 1, Y = 1 }, new SimplePoint() { X = 2, Y = 1 } } }, new LineSegment() { Coordinates = new SimplePoint[] { new SimplePoint() { X = 2, Y = 2 }, new SimplePoint() { X = 1, Y = 2 } } }, new LineSegment() { Coordinates = new SimplePoint[] { new SimplePoint() { X = 2, Y = 1 }, new SimplePoint() { X = 2, Y = 2 } } }, new LineSegment() { Coordinates = new SimplePoint[] { new SimplePoint() { X = 1, Y = 2 }, new SimplePoint() { X = 1, Y = 1 } } } }); Assert.AreEqual("Square", square.GetShapeType()); }