コード例 #1
0
        public void Area_2_4_8()
        {
            double a = 2, b = 4, c = 8;
            double expected = 4;

            double actual = TriangleArea.Area(a, b, c);

            Assert.AreEqual(expected, actual);
        }
コード例 #2
0
        public void Area_3_4_5()
        {
            double a = 3, b = 4, c = 5;
            double expected = 6;

            double actual = TriangleArea.Area(a, b, c);

            Assert.AreEqual(expected, actual);
        }
コード例 #3
0
        public void RightValues_Test()
        {
            // Arrange
            double a     = 6;
            double b     = 8;
            double c     = 10;
            double area1 = 24;
            double area2 = TriangleArea.Area(a, b, c);

            Assert.AreEqual(area1, area2);
        }
コード例 #4
0
        public void TriangleExists_Test()
        {
            double a = 1;
            double b = 2;
            double c = 3;

            try
            {
                TriangleArea.Area(a, b, c);
            }
            catch (ArgumentException e)
            {
                StringAssert.Contains(e.Message, ConstMessage.WrongValues);
            }
        }
コード例 #5
0
        public void SquaredParametersInfinity_Test()
        {
            double a = double.MaxValue / 2;
            double b = 15;
            double c = double.MaxValue - 10;

            try
            {
                TriangleArea.Area(a, b, c);
            }
            catch (ArgumentException e)
            {
                StringAssert.Contains(e.Message, ConstMessage.SquaredParameterInfinity);
            }
        }
コード例 #6
0
        public void IncorrectLegLength_Test()
        {
            double a = 9;
            double b = 9;
            double c = 8;

            try
            {
                TriangleArea.Area(a, b, c);
            }
            catch (ArgumentException e)
            {
                StringAssert.Contains(e.Message, ConstMessage.TwoBigEqualsSides);
            }
        }
コード例 #7
0
        public void NegativeValue_Test()
        {
            // Arrange
            double a = -6;
            double b = 8;
            double c = 10;

            try
            {
                TriangleArea.Area(a, b, c);
            }
            catch (ArgumentException e)
            {
                StringAssert.Contains(e.Message, ConstMessage.NegativeValues);
            }
        }