public void DoubleAbcConstructor()
 {
     //Arrange
     Triangle t = new Triangle(1, 1, 1);
     //Act
     bool result = t.isEquilateral();
     //Assert
     Assert.IsTrue(result);
 }
示例#2
0
        public void TestTriangleCorrectArea()
        {
            Triangle triangle = new Triangle(5, 7, 8.6);

            double expectedArea = ( 5D * 7D ) / 2;
            double actualArea = triangle.Area();

            Assert.AreEqual(expectedArea, actualArea, 1e-5);
        }
示例#3
0
        public void SimpleTriangleIsOK()
        {
            Triangle t = new Triangle(12, 16, 20);

            var expectedResult = 96;
            var actualResult = t.GetArea();

            Assert.AreEqual(expectedResult, actualResult);
        }
 public void DoubleArrayConstructor()
 {
     //Arrange
     double[] sides = {1, 1, 1};
     Triangle t = new Triangle(sides);
     //Act
     bool result = t.isEquilateral();
     //Assert
     Assert.IsTrue(result);
 }
        public void NotCongruent_TestTriangles_Correct(Triangle triangle1, Triangle triangle2, bool isEquals)
        {
            string errorMessage = triangle1 + "; " + triangle2;

            bool result1 = triangle1 != triangle2;
            bool result2 = triangle2 != triangle1;

            Assert.That(result1 != isEquals, errorMessage);
            Assert.That(result2 != isEquals, errorMessage);
        }
        public void Equality_NullTriangles_False()
        {
            Triangle triangle1 = new Triangle(2, 2.5, 4);
            Triangle triangle2 = null;
            object objTriangle2 = null;

            bool result1 = triangle1.Equals(triangle2);
            bool result2 = triangle1.Equals(objTriangle2);

            Assert.That(result1 == false);
            Assert.That(result2 == false);
        }
        public void Equals_TestTriangles_Correct(Triangle triangle1, Triangle triangle2, bool isEquals)
        {
            object objTriangle1 = triangle1;
            object objTriangle2 = triangle2;
            string errorMessage = triangle1 + "; " + triangle2;

            bool result1 = triangle1.Equals(triangle2);
            bool result2 = triangle2.Equals(triangle1);
            bool result3 = triangle1.Equals(objTriangle2);
            bool result4 = triangle2.Equals(objTriangle1);

            Assert.That(result1 == isEquals, errorMessage);
            Assert.That(result2 == isEquals, errorMessage);
            Assert.That(result3 == isEquals, errorMessage);
            Assert.That(result4 == isEquals, errorMessage);
        }
示例#8
0
    public HomeModule()
    {
      Get["/"] = _ => {
        return View["form.html", new Triangle(0, 0, 0)];
      };
      Get["/triangle"] = _ => {
        int Side1 = 0;
        int.TryParse(Request.Query["Side1"], out Side1);
        int Side2 = 0;
        int.TryParse(Request.Query["Side2"], out Side2);
        int Side3 = 0;
        int.TryParse(Request.Query["Side3"], out Side3);

        Triangle triangle = new Triangle(Side1, Side2, Side3);
        if (Side1 == 0 || Side2 == 0 || Side3 == 0 || !triangle.IsTriangle())
        {
          return View["form.html", triangle];
        }
        else{
          return View["result.html", triangle];
        }
      };
    }
        public void SerializeAndDeserialize_Triangle_Success()
        {
            Triangle triangle1 = new Triangle(1, 1.5, 2);

            //Serialize triangle to triangleBytes
            byte[] triangleBytes;
            BinaryFormatter bf1 = new BinaryFormatter();
            using (MemoryStream ms = new MemoryStream())
            {
                bf1.Serialize(ms, triangle1);
                triangleBytes = ms.ToArray();
            }

            //Deserialize triangleBytes to triangle
            Triangle triangle2;
            BinaryFormatter bf2 = new BinaryFormatter();
            using (MemoryStream ms = new MemoryStream(triangleBytes, 0, triangleBytes.Length))
            {
                triangle2 = (Triangle) bf2.Deserialize(ms);
            }

            Assert.That(triangle1.Equals(triangle2));
        }
示例#10
0
 public void TriangleNegativeInputs()
 {
     Triangle t = new Triangle(0, 4, 6);
     var res = t.GetArea();
 }
 public void TriangleIsEquilateral()
 {
     //Arrange
     Triangle t = new Triangle(1, 1, 1);
     //Act
     bool result = t.isEquilateral();
     //Assert
     Assert.IsTrue(result);
 }
 public void TriangleIsNotEquilateral()
 {
     //Arrange
     Triangle t = new Triangle(1, 2, 3);
     //Act
     bool result = t.isEquilateral();
     //Assert
     Assert.IsFalse(result);
 }
 public void PointAbcNoEqualCoords2()
 {
     Point a = new Point(0, 0);
     Point b = new Point(5, 0);
     Triangle t = new Triangle(a, b, a);
 }
 public void DoubleArrayRejectsMoreThanThree()
 {
     double[] sides = { 1, 2, 3, 4 };
     Triangle t = new Triangle(sides);
 }
 public void DoubleArrayRejectsLessThanThree()
 {
     double[] sides = { 1, 2};
     Triangle t = new Triangle(sides);
 }
        public void PointsArrayConstructor()
        {
            //Arrange
            Point a = new Point(0, 0);
            Point b = new Point(5, 0);
            Point c = new Point(0, 5);
            Point[] points = { a, b, c };

            Triangle t = new Triangle(points);
            //Act
            bool result = t.isIsosceles();
            //Assert
            Assert.IsTrue(result);
        }
示例#17
0
        /// <summary>
        /// Return TRUE if the triangles are identity.
        /// </summary>
        /// <param name="triangle">Triangle for equals</param>
        /// <returns>Boolean</returns>
        public bool Equals(Triangle triangle)
        {
            if (ReferenceEquals(this, triangle))
                return true;

            if (triangle == null)
            {
                return false;
            }

            for (int i = 0; i <= 2; i++)
            {
                if (Math.Abs(sideArray[i] - triangle.sideArray[i]) > delta)
                    return false;
            }

            return true;
        }
 public void DoubleAbcNoZeroSides()
 {
     Triangle t = new Triangle(0, 1, 1);
 }
 public void DoubleAbcNoNegativeSides()
 {
     Triangle t = new Triangle(-1, 1, 1);
 }
 public void TriangleIsScalene()
 {
     //Arrange
     Triangle t = new Triangle(10, 20, 15);
     //Act
     bool result = t.isScalene();
     //Assert
     Assert.IsTrue(result);
 }
 public void TriangleIsNotIsosceles()
 {
     //Arrange
     Triangle t = new Triangle(10, 11, 15);
     //Act
     bool result = t.isIsosceles();
     //Assert
     Assert.IsFalse(result);
 }
        public void PointArrayRejectsLessThanThree()
        {
            Point a = new Point(1, 1);
            Point b = new Point(2, 1);

            Point[] points = { a, b};
            Triangle t = new Triangle(points);
        }
        public void PointArrayNoEqualCoords3()
        {
            Point a = new Point(1, 1);
            Point b = new Point(2, 3);

            Point[] points = { a, a, b };
            Triangle t = new Triangle(points);
        }
 public void DoubleArrayNoZeroSides()
 {
     double[] sides = { 0, 1, 1 };
     Triangle t = new Triangle(sides);
 }
        public void PointArrayRejectsMoreThanThree()
        {
            Point a = new Point(1, 1);
            Point b = new Point(2, 1);
            Point c = new Point(13, 1);
            Point d = new Point(12, 1);

            Point[] points = { a, b, c, d };
            Triangle t = new Triangle(points);
        }
示例#26
0
 public void TriangleNotExists()
 {
     Triangle t = new Triangle(2, 3, 6);
     var res = t.GetArea();
 }
 public void DoubleArrayNoNegativeSides()
 {
     double[] sides = { -1, 1, 1 };
     Triangle t = new Triangle(sides);
 }