Exemplo n.º 1
0
        public void BadScaleTest()
        {
            List <Point> points = new List <Point>();

            var rectangle = new Rectangle(
                new Point(20, 20),
                new Point(30, 20),
                new Point(30, 30),
                new Point(20, 30));

            Assert.That(() => rectangle.Scale(-20), Throws.TypeOf <ShapeException>()
                        .With.Message.EqualTo("Invalid scale factor"));
        }
Exemplo n.º 2
0
        public void ScaleTest()
        {
            List <Point> points = new List <Point>();

            var rectangle = new Rectangle(
                new Point(20, 20),
                new Point(30, 20),
                new Point(30, 30),
                new Point(20, 30));

            points.Add(new Point(20, 20));
            points.Add(new Point(30, 20));
            points.Add(new Point(30, 30));
            points.Add(new Point(20, 30));
            rectangle.Scale(10);
            for (int i = 0; i < rectangle.Points.Count; i++)
            {
                points[i].X *= 10;
                points[i].Y *= 10;
                Assert.AreEqual(points[i].X, rectangle.Points[i].X);
                Assert.AreEqual(points[i].Y, rectangle.Points[i].Y);
            }
        }