Example #1
0
        public void SetLength_input4_expectLenghtEquals4()
        {
            //Arrange
            int            l             = 4;
            int            w             = 5;
            TriangleSolver testRectangle = new TriangleSolver(l, w);

            //Act
            int length = testRectangle.SetLength(4);

            Assert.AreEqual(length, l);
        }
        public void AnalyzeTest_input_0_10_10_Expect_Not_a_triangle()
        {
            // Arrange
            int s1 = 0;
            int s2 = 10;
            int s3 = 10;
            // Act
            string response = TriangleSolver.Analyze(s1, s2, s3);

            //Assert
            Assert.AreEqual(response, "Not a triangle");
        }
Example #3
0
        public void AnalyzeTest1()
        {
            //Arrange
            int a = 3;
            int b = 3;
            int c = 3;

            //Act
            string output = TriangleSolver.Analyze(a, b, c);

            Assert.AreEqual("Equilateral", output);
        }
        public void AnalyzeTest_input_1500_2000_2500_Expect_Scalene()
        {
            // Arrange
            int s1 = 1500;
            int s2 = 2000;
            int s3 = 2500;
            // Act
            string response = TriangleSolver.Analyze(s1, s2, s3);

            //Assert
            Assert.AreEqual(response, "Scalene");
        }
        public void SidesNegativeand3and4forNotPossible()
        {
            //Arrange
            int s1 = -5, s2 = 3, s3 = 4;

            //Act
            String length = TriangleSolver.Analyze(s1, s2, s3);

            //Assert
            Assert.AreEqual(length, "Trinagle is Not Posssible");
            Console.WriteLine("Please check the result");
        }
        public void AnalyzeTest_input_100_100_100_Expect_Equilateral()
        {
            // Arrange
            int s1 = 100;
            int s2 = 100;
            int s3 = 100;
            // Act
            string response = TriangleSolver.Analyze(s1, s2, s3);

            //Assert
            Assert.AreEqual(response, "Equilateral");
        }
        public void Input100_1_102_OutputValid()
        {
            Sides sides = new Sides();

            sides.a = 100; sides.b = 1; sides.c = 102;

            String expected_result = "Sides doesn't form a Triangle\n";

            String actual_result = TriangleSolver.Analyze(sides);

            Assert.AreEqual(expected_result, actual_result);
        }
        public void SidesNegateiveand2forNOTPOSSIBLE()
        {
            //Arrange
            int s1 = -5, s2 = -11, s3 = 2;

            //Act
            String length = TriangleSolver.Analyze(s1, s2, s3);

            //Assert
            Assert.AreEqual(length, "Two of the side are Negative, Triangle not Posssible");
            Console.WriteLine("Please check the result");
        }
        public void Input60_60_70_OutputValid()
        {
            Sides sides = new Sides();

            sides.a = 60; sides.b = 60; sides.c = 70;

            String expected_result = "Sides form a Triangle\nTriangle is Isosceles\n";

            String actual_result = TriangleSolver.Analyze(sides);

            Assert.AreEqual(expected_result, actual_result);
        }
Example #10
0
        public void Analyze_NotValidTriangle_GivenInputs5_6_11_output_Not_valid_traingle()
        {
            // Arrange
            String actual   = " ";
            String expected = "Not valid traingle";

            // Act
            actual = TriangleSolver.Analyze(5, 6, 11);

            // Assert
            Assert.AreEqual(expected, actual);
        }
        public void AnalyzeTest_input_150_150_20_Expect_Isosceles()
        {
            // Arrange
            int s1 = 150;
            int s2 = 150;
            int s3 = 20;
            // Act
            string response = TriangleSolver.Analyze(s1, s2, s3);

            //Assert
            Assert.AreEqual(response, "Isosceles");
        }
        public void Input15_15_15_OutputValid()
        {
            Sides sides = new Sides();

            sides.a = 15; sides.b = 15; sides.c = 15;

            String expected_result = "Sides form a Triangle\nTriangle is Equilateral\n";

            String actual_result = TriangleSolver.Analyze(sides);

            Assert.AreEqual(expected_result, actual_result);
        }
        public void Sides10and6and6forIsosceles()
        {
            //Arrange
            int s1 = 10, s2 = 6, s3 = 6;

            //Act
            String length = TriangleSolver.Analyze(s1, s2, s3);

            //Assert
            Assert.AreEqual(length, "It's Isosceles");
            Console.WriteLine("Please check the result");
        }
        public void SidesnegativeforNOTPOSSIBLE()
        {
            //Arrange
            int s1 = -1, s2 = -2, s3 = -3;

            //Act
            String length = TriangleSolver.Analyze(s1, s2, s3);

            //Assert
            Assert.AreEqual(length, "All sides enterred are less then zero, Triangle not possible");
            Console.WriteLine("Please check the result");
        }
        public void Sides7and7and4forNotPossible()
        {
            //Arrange
            int s1 = 7, s2 = 7, s3 = 4;

            //Act
            String length = TriangleSolver.Analyze(s1, s2, s3);

            //Assert
            Assert.AreEqual(length, "It's Isosceles");
            Console.WriteLine("Please check the result");
        }
        public void Sides5and5and5forEquilateral()
        {
            //Arrange
            int s1 = 5, s2 = 5, s3 = 5;

            //Act
            String length = TriangleSolver.Analyze(s1, s2, s3);

            //Assert
            Assert.AreEqual(length, "It's Equilateral");
            Console.WriteLine("Please check the result");
        }
Example #17
0
        public void testTriangleFormation()
        {
            TriangleSolver ts = new TriangleSolver();

            string resultArea = ts.Analyze(5, 5, 10);

            Assert.AreEqual("It is not a triangle", resultArea);

            string resultArea2 = ts.Analyze(5, 6, 10);

            Assert.AreEqual("It is a triangle and the triangle is Scalene", resultArea2);
        }
Example #18
0
        public void AnalyzeMethod_GivenInputs_4_4_2_Result_Isosceles_Triangle()
        {
            // Arrange
            String actual   = " ";
            String expected = "This is a valid Isosceles triangle";

            // Act
            actual = TriangleSolver.Analyze(4, 4, 2);

            // Assert
            Assert.AreEqual(expected, actual);
        }
Example #19
0
        public void AnalyzeMethod_GivenInput_9_9_9_Result_Equilateral_Traingle()
        {
            //Arrange
            String actual   = "";
            String expected = "This is a valid Equilateral triangle";

            //Act
            actual = TriangleSolver.Analyze(9, 9, 9);

            //Assert
            Assert.AreEqual(expected, actual);
        }
        public void Sides3and3and3forEquilateral()
        {
            //Arrange
            int s1 = 3, s2 = 3, s3 = 3;

            //Act
            String length = TriangleSolver.Analyze(s1, s2, s3);

            //Assert
            Assert.AreEqual(length, "This is an Equilateral triangle");
            Console.WriteLine("Please check the result");
        }
        public void Sides2and3and4forIsosceles()
        {
            //Arrange
            int s1 = 2, s2 = 3, s3 = 4;

            //Act
            String length = TriangleSolver.Analyze(s1, s2, s3);

            //Assert
            Assert.AreEqual(length, "It's Scalene");
            Console.WriteLine("Please check the result");
        }
        public void Sides3and2and2forIsosceles()
        {
            //Arrange
            int s1 = 3, s2 = 2, s3 = 2;

            //Act
            String length = TriangleSolver.Analyze(s1, s2, s3);

            //Assert
            Assert.AreEqual(length, "This is an Isosceles triangle");
            Console.WriteLine("Please check the result");
        }
        public void Input3_4_5_OutputValid()
        {
            Sides sides = new Sides();

            sides.a = 3; sides.b = 4; sides.c = 5;

            String expected_result = "Sides form a Triangle\nTriangle is Scalene\n";

            String actual_result = TriangleSolver.Analyze(sides);

            Assert.AreEqual(expected_result, actual_result);
        }
        static void Main(string[] args)
        {
restartProgram:
            Console.Clear();
            Console.WriteLine("\n 1. Enter triangle dimension");
            Console.WriteLine("\n 2. Exit");
            Console.WriteLine(" Please Enter your choice number");
            int a = int.Parse(Console.ReadLine());

            switch (a)
            {
            case 1:
                Console.WriteLine("Please Enter three sides for triangle");
                int x1 = int.Parse(Console.ReadLine());
                int x2 = int.Parse(Console.ReadLine());
                int x3 = int.Parse(Console.ReadLine());

                //Get output from method that validate the form is trinagle or not.
                var outPut = TriangleSolver.Analyze(x1, x2, x3);

                switch (outPut)
                {
                // verify  the output in switch statement for show user to diffrent type of trinagle.
                case "Equilateral":
                    Console.WriteLine("This points makes a trinagle that is Equilateral ");
                    break;

                case "Isosceles":
                    Console.WriteLine("This points makes a trinagle that is  Isosceles ");
                    break;

                case "Scalene":
                    Console.WriteLine("This points makes a trinagle that is  Scalene ");
                    break;

                default:
                    // In default case print the form is not Trinagle.
                    Console.WriteLine(outPut);
                    break;
                }

                break;

            case 2:
                Environment.ExitCode = 0;
                Environment.Exit(0);
                break;

            default:
                goto restartProgram;     // This goto statement is used to restart program in case user enter invalid input.
            }
        }
        public void NegativeValues_expectNotaTriangle()
        {
            //Arrange
            int l = -1;
            int b = -1;
            int h = -1;

            //Act
            string report = TriangleSolver.Analyze(l, b, h);

            //Assert
            Assert.AreEqual("Triangle cannot be formed", report);
        }
        public void InvalidInput_expectNotaTriangle()
        {
            //Arrange
            int l = 0;
            int b = 6;
            int h = 3;

            //Act
            string report = TriangleSolver.Analyze(l, b, h);

            //Assert
            Assert.AreEqual("Triangle cannot be formed", report);
        }
        public void Threevalidside_expectScaleneTriangle()
        {
            //Arrange
            int l = 4;
            int b = 5;
            int h = 7;

            //Act
            string report = TriangleSolver.Analyze(l, b, h);

            //Assert
            Assert.AreEqual("This is a Scalene Triangle", report);
        }
        public void TwoSidesEqual_expectIsoscelesTriangle()
        {
            //Arrange
            int l = 6;
            int b = 6;
            int h = 3;

            //Act
            string report = TriangleSolver.Analyze(l, b, h);

            //Assert
            Assert.AreEqual("This is an Isosceles Triangle", report);
        }
        public void ThreeSidesEqual_expectEquilateralTriangle()
        {
            //Arrange
            int l = 6;
            int b = 6;
            int h = 6;

            //Act
            string report = TriangleSolver.Analyze(l, b, h);

            //Assert
            Assert.AreEqual("This is an Equilateral Triangle", report);
        }
        public void Sumoftwoside_expectNotaTriangle()
        {
            //Arrange
            int l = 2;
            int b = 2;
            int h = 4;

            //Act
            string report = TriangleSolver.Analyze(l, b, h);

            //Assert
            Assert.AreEqual("Triangle cannot be formed", report);
        }