Exemple #1
0
        public void GetAddition_Input16and30_Return46()
        {
            //Arrange
            double Value1 = 16;
            double Value2 = 30;

            double expectedResult = Value1 + Value2;

            Calc1 testCalc1 = new Calc1(Value1, Value2);

            //Act
            double actualResult = testCalc1.GetAddition();

            //Assert
            Assert.AreEqual(expectedResult, actualResult);
        }
Exemple #2
0
        public void GetAddition_Input15point4and23point3_Return38point7()
        {
            //Arrange

            double Value1 = 15.4;
            double Value2 = 23.3;

            double expectedResult = Value1 + Value2;
            Calc1  testCalc1      = new Calc1(Value1, Value2);

            //Act
            double actualResult = testCalc1.GetAddition();

            //Assert

            Assert.AreEqual(expectedResult, actualResult);
        }
Exemple #3
0
        public void GetSubtraction_Input24point8and12point4_Return12point4()
        {
            //Arrange

            double Value1 = 24.8;
            double Value2 = 12.4;

            double expectedResult = Value1 - Value2;
            Calc1  testCalc1      = new Calc1(Value1, Value2);

            //Act

            double actualResult = testCalc1.GetSubtraction();

            //Assert

            Assert.AreEqual(expectedResult, actualResult);
        }
Exemple #4
0
        public void GetSubtraction_Input68and22_Return46()
        {
            //Arrange

            double Value1         = 68;
            double Value2         = 22;
            double expectedResult = Value1 - Value2;

            Calc1 testCalc1 = new Calc1(Value1, Value2);

            //Act

            double actualResult = testCalc1.GetSubtraction();

            //Assert

            Assert.AreEqual(expectedResult, actualResult);
        }
Exemple #5
0
        public void GetAddition_Input225and425_Return650()
        {
            //Arrange

            double Value1 = 225;
            double Value2 = 425;

            double expectedResult = Value1 + Value2;
            Calc1  testCalc1      = new Calc1(Value1, Value2);

            //Act

            double actualResult = testCalc1.GetAddition();

            //Assert

            Assert.AreEqual(expectedResult, actualResult);
        }
Exemple #6
0
        public void GetDivision_Input26point8and2_Return13point4()
        {
            //Arrange

            double Value1 = 26.8;
            double Value2 = 2;

            double expectedResult = Value1 / Value2;
            Calc1  testCalc1      = new Calc1(Value1, Value2);

            //Act

            double actualResult = testCalc1.GetDivision();

            //Assert

            Assert.AreEqual(expectedResult, actualResult);
        }
Exemple #7
0
        public void GetDivision_Input2250and90_Return25()
        {
            //Arrange

            double Value1 = 2250;
            double Value2 = 90;

            double expectedResult = Value1 / Value2;
            Calc1  testCalc1      = new Calc1(Value1, Value2);

            //Act

            double actualResult = testCalc1.GetDivision();

            //Assert

            Assert.AreEqual(expectedResult, actualResult);
        }
Exemple #8
0
        public void GetMultiplication_Input40and250_Return10000()
        {
            //Arrange

            double Value1 = 40;
            double Value2 = 250;

            double expectedResult = Value1 * Value2;
            Calc1  testCalc1      = new Calc1(Value1, Value2);

            //Act

            double actualResult = testCalc1.GetMultiplication();

            //Assert

            Assert.AreEqual(expectedResult, actualResult);
        }
Exemple #9
0
        public void GetMultiplication_Input4point4and2_Return8point8()
        {
            //Arrange

            double Value1 = 4.4;
            double Value2 = 2;

            double expectedResult = Value1 * Value2;
            Calc1  testCalc1      = new Calc1(Value1, Value2);

            //Act

            double actualResult = testCalc1.GetMultiplication();

            //Assert

            Assert.AreEqual(expectedResult, actualResult);
        }
Exemple #10
0
        public void GetMultiplication_Input24and4_Return96()
        {
            //Arrange

            double Value1 = 24;
            double Value2 = 4;

            double expectedResult = Value1 * Value2;
            Calc1  testCalc1      = new Calc1(Value1, Value2);

            //Act

            double actualResult = testCalc1.GetMultiplication();

            //Assert

            Assert.AreEqual(expectedResult, actualResult);
        }
Exemple #11
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");

            var calc = new Calc1();
        }
Exemple #12
0
        static void Main(string[] args)
        {
            Calc1  c = new Calc1();
            bool   validCalcSelect = false;
            string calcSelection;
            int    selection;

            while (validCalcSelect == false)
            {
                Console.WriteLine("1 = Use random numbers between 0 and 501 for your calculation\n");
                Console.WriteLine("2 = Provide your own numbers\n");
                Console.WriteLine("Choose a menu item to begin:");
                calcSelection = Console.ReadLine();
                Console.WriteLine();

                if (calcSelection != "1" && calcSelection != "2")
                {
                    Console.WriteLine("That's not a valid selection, please try again.\n");
                }
                else if (int.Parse(calcSelection) == 1)
                {
                    validCalcSelect = true;
                    Random random = new Random();
                    double firstNumber;
                    double secondNumber;

                    firstNumber  = Math.Round((random.NextDouble() * 500), 2);
                    secondNumber = Math.Round((random.NextDouble() * 500), 2);

                    Console.WriteLine($"Your random numbers are {firstNumber} and {secondNumber}.\n");
                    Calc1 customCalc = new Calc1(firstNumber, secondNumber);
                    c = customCalc;
                }
                else if (int.Parse(calcSelection) == 2)
                {
                    validCalcSelect = true;

                    double firstNumber;
                    double secondNumber;

                    firstNumber  = ValidateUserInput("firstNumber");
                    secondNumber = ValidateUserInput("secondNumber");

                    Console.WriteLine($"Your custom numbers are {firstNumber} and {secondNumber}.\n");
                    Calc1 customCalc = new Calc1(firstNumber, secondNumber);
                    c = customCalc;
                }
            }


            selection = ValidateMenuSelection();

            while (selection != 9)
            {
                double result;

                switch (selection)
                {
                case 1:
                    Console.WriteLine($"First Number is: {c.GetFirstNumber()}\n");
                    break;

                case 2:
                    result = ValidateUserInput("firstNumber");
                    c.SetFirstNumber(result);
                    break;

                case 3:
                    Console.WriteLine($"Second Number is: {c.GetSecondNumber()}\n");
                    break;

                case 4:
                    result = ValidateUserInput("secondNumber");
                    c.SetSecondNumber(result);
                    break;

                case 5:
                    Console.WriteLine($"The result of {c.GetFirstNumber()} + {c.GetSecondNumber()} is: {c.GetAddition()}\n");
                    break;

                case 6:
                    Console.WriteLine($"The result of {c.GetFirstNumber()} - {c.GetSecondNumber()} is: {c.GetSubtraction()}\n");
                    break;

                case 7:
                    Console.WriteLine($"The result of {c.GetFirstNumber()} * {c.GetSecondNumber()} is: {c.GetMultiplication()}\n");
                    break;

                case 8:
                    Console.WriteLine($"The result of {c.GetFirstNumber()} / {c.GetSecondNumber()} is: {c.GetDivision()}\n");
                    break;

                default:
                    break;
                }

                selection = ValidateMenuSelection();
            }
        }
Exemple #13
0
        public static void Main()
        {
            Calc1 calc1 = new Calc1();

            calc1.Menu();
        }