Beispiel #1
0
        public void TriangleIsRight_FuzzyTest()
        {
            var rnd = new Random();

            var a = rnd.NextDouble();
            var b = rnd.NextDouble();
            var c = Math.Sqrt(a * a + b * b);

            if (a > b)
            {
                (a, b) = (b, a);
            }
            if (b > c)
            {
                (b, c) = (c, b);
            }

            var expected = Math.Abs(a * a + b * b - c * c) < Constants.FloatingPointPrecision;

            var actual = TestThat.TriangleIsRight(a, b, c);

            Assert.Equal(expected, actual);
        }
Beispiel #2
0
        public void TriangleIsRight_BasicTest(double a, double b, double c, bool expected)
        {
            var actual = TestThat.TriangleIsRight(a, b, c);

            Assert.Equal(expected, actual);
        }
Beispiel #3
0
        public void TriangleIsRight_NonPositiveArgumentsTest(double a, double b, double c)
        {
            var exception = Assert.Throws <ArgumentException>(() => TestThat.TriangleIsRight(a, b, c));

            Assert.StartsWith("Side length should not be negative.", exception.Message);
        }