static void Main(string[] args) { Console.WriteLine("Hello to Calc Test!"); Console.WriteLine(string.Format("{0} + {1} = {2}", 20, 22, BasicMath.Sum(20, 22))); Console.WriteLine(string.Format("{0} - {1} = {2}", 50, 8, BasicMath.Difference(50, 8))); Console.WriteLine(string.Format("{0} * {1} = {2}", 7, 6, BasicMath.Multiplication(7, 6))); Console.WriteLine(string.Format("{0} / {1} = {2}", 420, 10, BasicMath.Division(420, 10))); }
public void DivideNumbers(double a, double b, double expected) { /// action BasicMath cal1 = new BasicMath(); double actual = cal1.Division(a, b); /// assertion Assert.Equal(expected, actual); }
protected void btnDivision_Click(object sender, EventArgs e) { GetNumbers(1, 10, "/"); answer = m.Division(); int remainder = m.Remainder(); Session["answer"] = answer; Session["remainder"] = remainder; }
public void DivideNumbers(int a, int b, int expected) { //action BasicMath calc3 = new BasicMath(); int actual = calc3.Division(a, b); //assertion Assert.Equal(expected, actual); //Assert.eq }
public void DivideByZero() { //arrange double expected = 0; // action BasicMath cal1 = new BasicMath(); double actual = cal1.Division(15, 0); // assertion Assert.Equal(expected, actual); }
public void Should_True_Zero_One_And_Second_NUmber_Division() { //Arrange double oneNumber = 0; double twoNumber = 0; double divisionNumber = 1; double division; //Act division = BasicMath.Division(oneNumber, twoNumber); //Assert Assert.Equal(divisionNumber, division); }
public void Should_True_Zero_First_Number_Division() { //Arrange double oneNumber = 0; double twoNumber = 5; double divisionNumber = 0; double division; //Act division = BasicMath.Division(oneNumber, twoNumber); //Assert Assert.Equal(divisionNumber, division); }
public void Should_True_Two_Number_Division() { //Arrange double oneNumber = 65; double twoNumber = 77; double divisionNumber; double division; //Act divisionNumber = oneNumber / twoNumber; division = BasicMath.Division(oneNumber, twoNumber); //Assert Assert.Equal(divisionNumber, division); }
private void BtnEquals_Click(object sender, EventArgs e) { /*depending on the last button to be clicked perform the correct operation * and output the result to the user */ if (!(multiplyButtonClicked && minusButtonClicked && plusButtonClicked && divisionButtonClicked) && CheckForInput(tbResult.Text)) { total = double.Parse(tbResult.Text); } if (!double.TryParse(tbResult.Text, out double lastInput)) { return; } if (plusButtonClicked) { total = BasicMath.Addition(valueHolder, lastInput); } else if (minusButtonClicked) { total = BasicMath.Subtraction(valueHolder, lastInput); } else if (multiplyButtonClicked) { total = BasicMath.Multiplication(valueHolder, lastInput); } else if (divisionButtonClicked) { if (BasicMath.Division(valueHolder, lastInput, out double setTotal)) { total = setTotal; } else { MessageBox.Show("Error: Cannot Divide By Zero"); return; } } //print result tbResult.Text = $"{total}"; //reset calculator valueHolder = 0; total = 0; isTotal = true; plusButtonClicked = minusButtonClicked = divisionButtonClicked = multiplyButtonClicked = false; }
private void BtnDivide_Click(object sender, EventArgs e) { //if there's valid input call the Third Party library and perform the Division function if (CheckForInput(tbResult.Text)) { //if this is the first input set valueHolder to the input if (!(plusButtonClicked && multiplyButtonClicked && minusButtonClicked && divisionButtonClicked)) { valueHolder = double.Parse(tbResult.Text); } else { //If division returns true output result if (BasicMath.Division(valueHolder, double.Parse(tbResult.Text), out double a)) { valueHolder = a; } //If Division retuns false print error to user else { MessageBox.Show("Error: Cannot divide by zero"); } } tbResult.Clear(); plusButtonClicked = false; minusButtonClicked = false; divisionButtonClicked = true; multiplyButtonClicked = false; } //if invalid input print error to user else { MessageBox.Show("Please enter valid input"); } isTotal = false; }