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); }
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); }
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(); } }