示例#1
0
        public void TestAreaForDetectedRectangle()
        {
            // set sizes to 30, 20
            Box myBox = new Box(30.0f, 20f);
            Assert.AreEqual(600.0f, myBox.Area());

            // reset width to 40
            myBox.SetWidth(40f);
            Assert.AreEqual(1200.0f, myBox.Area());
        }
示例#2
0
        public void TestAreaForDetectedSquare()
        {
            // set size to 30
            Box myBox = new Box(30.0f);
            Assert.AreEqual(900.0f, myBox.Area());

            // reset size to 10
            myBox.SetLength(10f);
            Assert.AreEqual(100.0f, myBox.Area());

            // reset size to 0
            myBox.SetLength(0f);
            Assert.AreEqual(0f, myBox.Area());
        }
示例#3
0
 public void TestSquareArea()
 {
     Box myBox = new Box(30.0f);
     ISquare mySquareArea = myBox as ISquare;
     Assert.AreEqual(900.0f, mySquareArea.SurfaceArea());
 }
示例#4
0
 public void TestRectangleArea()
 {
     Box myBox = new Box(30.0f, 20.0f);
     IRectangle myRectangleArea = myBox as IRectangle;
     Assert.AreEqual(600.0f, myRectangleArea.SurfaceArea());
 }
示例#5
0
 public float Area()
 {
     if(shape == "square")
     {
         Box squareBox = new Box(lengthInches);
         ISquare squareArea = squareBox as ISquare;
         return squareArea.SurfaceArea();
     }
     else// if(shape == "square")
     {
         Box rectangleBox = new Box(lengthInches, widthInches);
         IRectangle squareArea = rectangleBox as IRectangle;
         return squareArea.SurfaceArea();
     }
 }