Esempio n. 1
0
        public void GetTriangleType_ValidTriangles_Equilateral()
        {
            var triangleService = new TriangleService();
            var resultsList     = new List <TriangleType>
            {
                triangleService.GetTriangleType(new Triangle(1, 1, 1)),
                triangleService.GetTriangleType(new Triangle(int.MaxValue, int.MaxValue, int.MaxValue)),
            };

            Assert.IsTrue(resultsList.All(r => r == TriangleType.Equilateral));
        }
Esempio n. 2
0
        public void GetTriangleType_ValidTriangles_Isosceles()
        {
            var triangleService = new TriangleService();
            var resultsList     = new List <TriangleType>
            {
                triangleService.GetTriangleType(new Triangle(4, 4, 6)),
                triangleService.GetTriangleType(new Triangle(int.MaxValue, 1, int.MaxValue)),
                triangleService.GetTriangleType(new Triangle(11, 1, 11)),
            };

            Assert.IsTrue(resultsList.All(r => r == TriangleType.Isosceles));
        }
Esempio n. 3
0
        public void GetTriangleType_ValidTriangles_Scalene()
        {
            var triangleService = new TriangleService();
            var resultsList     = new List <TriangleType>
            {
                triangleService.GetTriangleType(new Triangle(5, 6, 7)),
                triangleService.GetTriangleType(new Triangle(7, 6, 5)),
                triangleService.GetTriangleType(new Triangle(6, 5, 7))
            };

            Assert.IsTrue(resultsList.All(r => r == TriangleType.Scalene));
        }
Esempio n. 4
0
        public void TriangleType_InvalidTriangleSideLengths_ReturnsError()
        {
            var triangleService = new TriangleService();
            var actual          = triangleService.GetTriangleType(4, 4, 9);

            Assert.AreEqual("error", actual);
        }
Esempio n. 5
0
        public void TriangleType_SameSideLengths_ReturnsScalene()
        {
            var triangleService = new TriangleService();
            var actual          = triangleService.GetTriangleType(4, 5, 3);

            Assert.AreEqual("Scalene", actual);
        }
Esempio n. 6
0
        public void TriangleType_Same2SideLengths_ReturnsIsosceles()
        {
            var triangleService = new TriangleService();
            var actual          = triangleService.GetTriangleType(3, 5, 5);

            Assert.AreEqual("Isosceles", actual);
        }
Esempio n. 7
0
        public void TriangleType_SameSideLengths_ReturnsEquilateral()
        {
            var triangleService = new TriangleService();
            var actual          = triangleService.GetTriangleType(1, 1, 1);

            Assert.AreEqual("Equilateral", actual);
        }
Esempio n. 8
0
        public void TriangleType_InvalidNegativeSides_ReturnsError()
        {
            var triangleService = new TriangleService();
            var actual          = triangleService.GetTriangleType(1, -1, 1);

            Assert.AreEqual("error", actual);
        }
Esempio n. 9
0
        public void GetTriangleType_InvalidTriangeCoordinats_Error()
        {
            var triangleService = new TriangleService();
            var resultsList     = new List <TriangleType>
            {
                triangleService.GetTriangleType(new Triangle(0, 0, 0)),
                triangleService.GetTriangleType(new Triangle(1, 1, 2)),
                triangleService.GetTriangleType(new Triangle(-1, -1, -1)),
                triangleService.GetTriangleType(new Triangle(-1, 0, 1)),
                triangleService.GetTriangleType(new Triangle(1, 1, -1)),
                triangleService.GetTriangleType(new Triangle(9, 9, 9999)),
                triangleService.GetTriangleType(new Triangle(1, 1, int.MaxValue)),
                triangleService.GetTriangleType(new Triangle(int.MinValue, int.MinValue, int.MinValue)),
                triangleService.GetTriangleType(new Triangle(4, 4, 8)),
                triangleService.GetTriangleType(new Triangle(5, 6, 13))
            };

            Assert.IsTrue(resultsList.All(r => r == TriangleType.Error));
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            Console.WriteLine("Enter three integers:");

            try
            {
                var sideOne   = int.Parse(Console.ReadLine());
                var sideTwo   = int.Parse(Console.ReadLine());
                var sideThree = int.Parse(Console.ReadLine());

                var triangleService = new TriangleService(new PolygonService());

                Console.WriteLine(triangleService.GetTriangleType(sideOne, sideTwo, sideThree));
            }
            catch
            {
                Console.WriteLine("Invalid input.");
            }

            Console.ReadLine();
        }
Esempio n. 11
0
        public void GetTriangleType_NoEqualSides_ReturnsScalene(int sideOne, int sideTwo, int sideThree)
        {
            var triangleService = new TriangleService(new PolygonService());

            var results = new List <TriangleType>
            {
                triangleService.GetTriangleType(sideOne, sideTwo, sideThree),
                triangleService.GetTriangleType(sideOne, sideThree, sideTwo),
                triangleService.GetTriangleType(sideTwo, sideOne, sideThree),
                triangleService.GetTriangleType(sideTwo, sideThree, sideOne),
                triangleService.GetTriangleType(sideThree, sideOne, sideTwo),
                triangleService.GetTriangleType(sideThree, sideTwo, sideOne)
            };

            Assert.All(results, x => Assert.Equal(TriangleType.Scalene, x));
        }
Esempio n. 12
0
        [InlineData(3, 3, 10)]   // largest side exceeds smaller sides
        public void GetTriangleType_ImpossibleSides_ReturnsInvalidTriangle(int sideOne, int sideTwo, int sideThree)
        {
            var triangleService = new TriangleService(new PolygonService());

            var results = new List <TriangleType>
            {
                triangleService.GetTriangleType(sideOne, sideTwo, sideThree),
                triangleService.GetTriangleType(sideOne, sideThree, sideTwo),
                triangleService.GetTriangleType(sideTwo, sideOne, sideThree),
                triangleService.GetTriangleType(sideTwo, sideThree, sideOne),
                triangleService.GetTriangleType(sideThree, sideOne, sideTwo),
                triangleService.GetTriangleType(sideThree, sideTwo, sideOne)
            };

            Assert.All(results, x => Assert.Equal(TriangleType.NotAValidTriangle, x));
        }