Beispiel #1
0
        static void Main(string[] args)
        {
            int a, b, c = 0;
            ITriangleValidator    validator = new TriangleValidator();
            ITriangleDeterminator service   = new TriangleDeterminatorService(validator);

            Console.WriteLine("Guess the triangle");
            Console.WriteLine("==================");

            Console.Write("Enter length of Side 1 :");
            a = GetInt();

            Console.Write("Enter length of Side 2 :");
            b = GetInt();

            Console.Write("Enter length of Side 3 :");
            c = GetInt();

            Console.WriteLine();

            if (!validator.IsValid(a, b, c))
            {
                Console.WriteLine("Sorry, this is not a valid triangle.");
            }
            else
            {
                Console.WriteLine($"Your triangle is a {service.Determine(a, b, c)} triangle.");
            }

            Console.WriteLine("Press a key to exit.");
            Console.ReadKey();
        }
Beispiel #2
0
        public void Test_IsRight_Ok()
        {
            //given
            ITriangleDeterminator service = new TriangleDeterminatorService();

            //when
            TriangleType triangle = service.Determine(12, 35, 37);

            //then
            Assert.Equal(TriangleType.Right, triangle);
        }
Beispiel #3
0
        public void Test_IsObtuse_Ok()
        {
            //given
            ITriangleDeterminator service = new TriangleDeterminatorService();

            //when
            TriangleType triangle = service.Determine(5, 10, 14);

            //then
            Assert.Equal(TriangleType.Obtuse, triangle);
        }
Beispiel #4
0
        public void Test_IsAcute_Ok()
        {
            //given
            ITriangleDeterminator service = new TriangleDeterminatorService();

            //when
            TriangleType triangle = service.Determine(5, 6, 7);

            //then
            Assert.Equal(TriangleType.Acute, triangle);
        }
        public void Test_IsScalene_Ok()
        {
            //given
            ITriangleDeterminator service = new TriangleDeterminatorService();

            //when
            TriangleType triangle = service.Determine(4, 3, 2);

            //then
            Assert.Equal(TriangleType.Scalene, triangle);
        }
        public void Test_IsIsosceles_Ok()
        {
            //given
            ITriangleDeterminator service = new TriangleDeterminatorService();

            //when
            TriangleType triangle = service.Determine(4, 4, 3);

            //then
            Assert.Equal(TriangleType.Isosceles, triangle);
        }
        public void Test_IsEquilateral_Ok()
        {
            //given
            ITriangleDeterminator service = new TriangleDeterminatorService();

            //when
            TriangleType triangle = service.Determine(4, 4, 4);

            //then
            Assert.Equal(TriangleType.Equilateral, triangle);
        }