コード例 #1
0
        public void TestPointEquals()
        {
            var p1 = new inheritanceandpoly.Point(1, 2);
            var p2 = new inheritanceandpoly.Point(1, 2);

            var areEqual = p1.Equals(p2);

            Assert.IsTrue(areEqual);
        }
コード例 #2
0
        public void TestCircle()
        {
            var expectedCenter = new inheritanceandpoly.Point(1, 2);
            var expectedRadius = 5;
            var expectedName   = "Circle";

            var c = new inheritanceandpoly.Circle(expectedCenter, expectedRadius);

            //Assert
            Assert.AreEqual(expectedCenter, c.Center);
            Assert.AreEqual(expectedRadius, c.Radius);
            Assert.AreEqual(expectedName, c.Name);
        }
コード例 #3
0
        public void TestCircleArea()
        {
            var expectedRadius = 5;
            var center         = new inheritanceandpoly.Point(1, 2);
            var expectedArea   = Math.PI * expectedRadius * expectedRadius;

            var c = new inheritanceandpoly.Circle(center, expectedRadius);

            //act
            var actual = c.Area;

            //Assert

            Assert.AreEqual(expectedArea, actual);
        }
コード例 #4
0
        public void SquareTestCont()
        {
            var expectedLenght = 5;
            var expectedPoint  = new inheritanceandpoly.Point(1, 2);
            var expectedName   = "Square";

            var s = new inheritanceandpoly.Square(expectedPoint, expectedLenght);

            //Assert
            Assert.AreEqual(expectedPoint, s.TopLeft);
            Assert.AreEqual(expectedLenght, s.Width);
            Assert.AreEqual(expectedLenght, s.Height);

            Assert.AreEqual(expectedName, s.Name);
        }
コード例 #5
0
        public void TestRectangleEqual()
        {
            var expectedWidth = 10;
            var p1            = new inheritanceandpoly.Point(1, 2);
            var p2            = new inheritanceandpoly.Point(1, 2);

            var s1 = new inheritanceandpoly.Square(p1, expectedWidth);
            var s2 = new inheritanceandpoly.Square(p2, expectedWidth);
            var s3 = new inheritanceandpoly.Shape();

            //Assert

            Assert.AreEqual(s1, s2);
            Assert.AreNotEqual(s2, s3);
        }
コード例 #6
0
        public void TestRectangleCont()
        {
            var expectedHeight = 5;
            var expectedWidth  = 10;
            var expectedPoint  = new inheritanceandpoly.Point(1, 2);
            var expectedName   = "Rectangle";

            var r = new inheritanceandpoly.Rectangle(expectedPoint, expectedWidth, expectedHeight);

            //Assert
            Assert.AreEqual(expectedPoint, r.TopLeft);
            Assert.AreEqual(expectedWidth, r.Width);
            Assert.AreEqual(expectedHeight, r.Height);

            Assert.AreEqual(expectedName, r.Name);
        }
コード例 #7
0
        public void TestRectangleEqual()
        {
            var expectedHeight = 5;
            var expectedWidth  = 10;
            var p1             = new inheritanceandpoly.Point(1, 2);
            var p2             = new inheritanceandpoly.Point(1, 2);

            var r1 = new inheritanceandpoly.Rectangle(p1, expectedWidth, expectedHeight);
            var r2 = new inheritanceandpoly.Rectangle(p2, expectedWidth, expectedHeight);
            var r3 = new inheritanceandpoly.Shape();

            //Assert

            Assert.AreEqual(r1, r2);
            Assert.AreNotEqual(r2, r3);
        }
コード例 #8
0
        public void TestCicleConstructors()
        {
            var    p             = new inheritanceandpoly.Point(1, 2);
            var    expectedPoint = new inheritanceandpoly.Point(0, 0);
            int    r1            = 5;
            float  r2            = 6.0f;
            double r3            = 2.5;

            //act
            var c1 = new inheritanceandpoly.Circle(p, r1);
            var c2 = new inheritanceandpoly.Circle(p, r2);
            var c3 = new inheritanceandpoly.Circle(r3);

            // assert
            Assert.AreEqual(p, c1.Center);
            Assert.AreEqual(r1, c1.Radius);
            Assert.AreEqual(p, c2.Center);
            Assert.AreEqual(r2, c2.Radius);
            Assert.AreEqual(expectedPoint, c3.Center);
            Assert.AreEqual(r3, c3.Radius);
        }
コード例 #9
0
        public void TestCircleEquals()
        {
            var p1 = new inheritanceandpoly.Point(1, 2);
            var p2 = new inheritanceandpoly.Point(1, 2);

            var c3unequal      = new inheritanceandpoly.Circle(new inheritanceandpoly.Point(2, 2), 23894723);
            var expectedRadius = 5;

            var c5 = new inheritanceandpoly.Shape();

            var c1 = new inheritanceandpoly.Circle(p1, expectedRadius);
            var c2 = new inheritanceandpoly.Circle(p2, expectedRadius);
            var c4 = new inheritanceandpoly.Circle(null, expectedRadius);

            //Assert

            Assert.AreEqual(c1, c2);

            Assert.AreNotEqual(c2, c3unequal);
            Assert.AreEqual(c2, c1);
            Assert.AreNotEqual(c2, c5);
        }