public void FindRectangle() { //Arrange var points = new List <Point>() { new Point() { X = 1, Y = 2 }, new Point() { X = 3, Y = 6 }, new Point() { X = 2, Y = 4 } }; var expected = new Impl.Rectangle() { X = 1, Y = 2, Height = 4, Width = 1 }; //Act var actual = Service.FindRectangle(points); Console.WriteLine(actual); //Assert Assert.AreEqual((expected.GetType(), expected.X, expected.Y, expected.Height, expected.Width), (actual.GetType(), actual.X, actual.Y, actual.Height, actual.Width)); }
public void Success_TwoPoints_Vertical() { var points = new List <Point>() { new Point() { X = 5, Y = 1 }, new Point() { X = 5, Y = 7 } }; var actual = Service.FindRectangle(points); var expected = new Impl.Rectangle() { X = 5, Y = 7, Width = 1, Height = 1 }; Assert.AreEqual(expected.X, actual.X); Assert.AreEqual(expected.Y, actual.Y); Assert.AreEqual(expected.Width, actual.Width); Assert.AreEqual(expected.Height, actual.Height); }
public void FindRectangleByManyDots() { // Arrange List <Point> points = new List <Point>() { new Point(2, 2), new Point(4, 1), new Point(5, 4), new Point(2, 5), new Point(1, 3) }; Point LeftDownPoint = new Point(2, 1); Point RightDownPoint = new Point(5, 1); Point RightUpPoint = new Point(5, 5); Point LeftUpPoint = new Point(2, 5); Impl.Rectangle expected = new Impl.Rectangle(LeftDownPoint, RightDownPoint, RightUpPoint, LeftUpPoint); // Act Impl.Rectangle actual = Service.FindRectangleByManyDots(points); // Assert Assert.AreEqual(expected, actual); }
public void ValidResultWithOneMaxX() { //Arrange var points = TestData.rightPoints[3]; var expected = TestData.rightExpected[3]; //Act Impl.Rectangle rectangle = Service.FindRectangle(points); //Assert Assert.IsNotNull(rectangle); Assert.AreEqual(expected.X, rectangle.X); Assert.AreEqual(expected.Y, rectangle.Y); Assert.AreEqual(expected.Width, rectangle.Width); Assert.AreEqual(expected.Height, rectangle.Height); }
public void Success_OutPointOnTop() { var points = new List <Point>() { new Point() { X = 5, Y = 7 }, new Point() { X = 1, Y = 7 }, new Point() { X = 5, Y = 1 }, new Point() { X = 4, Y = 8 }, new Point() { X = 2, Y = 2 }, new Point() { X = 1, Y = 1 } }; var actual = Service.FindRectangle(points); var expected = new Impl.Rectangle() { X = 1, Y = 1, Width = 4, Height = 6 }; Assert.AreEqual(expected.X, actual.X); Assert.AreEqual(expected.Y, actual.Y); Assert.AreEqual(expected.Width, actual.Width); Assert.AreEqual(expected.Height, actual.Height); }
/// <summary> /// Use this method for local debugging only. The implementation should remain in Rectangle.Impl project. /// See TODO.txt file for task details. /// </summary> /// <param name="args"></param> static void Main(string[] args) { List <Point> points = new List <Point>() { new Point(2, 1), new Point(4, 1), new Point(5, 4), new Point(3, 5), new Point(1, 3), }; Impl.Rectangle rectangle = Service.FindRectangle(points); System.Console.WriteLine(rectangle.LeftUpPoint.X + ";" + rectangle.LeftUpPoint.Y + " " + rectangle.RightUpPoint.X + ";" + rectangle.RightUpPoint.Y); System.Console.WriteLine(); System.Console.WriteLine(rectangle.LeftDownPoint.X + ";" + rectangle.LeftDownPoint.Y + " " + rectangle.RightDownPoint.X + ";" + rectangle.RightDownPoint.Y); System.Console.WriteLine("Widht = " + rectangle.Width + " Height = " + rectangle.Height); System.Console.ReadKey(); }
public void FindRectangleByTwoDots() { // Arrange List <Point> points = new List <Point>() { new Point(1, 1), new Point(2, 2) }; Point LeftDownPoint = new Point(2, 2); Point RightDownPoint = new Point(3, 2); Point RightUpPoint = new Point(3, 3); Point LeftUpPoint = new Point(2, 3); Impl.Rectangle expected = new Impl.Rectangle(LeftDownPoint, RightDownPoint, RightUpPoint, LeftUpPoint); // Act var actual = Service.FindRectangleByTwoDots(points); // Assert Assert.AreEqual(expected, actual); }
public void Setup() { _rectangle = new Impl.Rectangle(); }