public void TestComplexParenMathWithDecimalInput() //1.457 + (4*(8/3)-6) = { var mockView = new MockView(); var controller = new CalculatorController(mockView); mockView.SendNumberPressed(1); mockView.SendModifierPressed(Modifier.Period); mockView.SendNumberPressed(4); mockView.SendNumberPressed(5); mockView.SendNumberPressed(7); mockView.SendOperatorPressed(Operator.Add); mockView.SendModifierPressed(Modifier.OpenParen); mockView.SendNumberPressed(4); mockView.SendOperatorPressed(Operator.Multiply); mockView.SendModifierPressed(Modifier.OpenParen); mockView.SendNumberPressed(8); mockView.SendOperatorPressed(Operator.Divide); mockView.SendNumberPressed(3); mockView.SendModifierPressed(Modifier.ClosedParen); mockView.SendOperatorPressed(Operator.Subtract); mockView.SendNumberPressed(6); mockView.SendModifierPressed(Modifier.ClosedParen); mockView.SendModifierPressed(Modifier.Equal); Assert.AreEqual("6.1237", mockView.Display); }
public void TestSimpleParenDisplay() { var mockView = new MockView(); var controller = new CalculatorController(mockView); mockView.SendNumberPressed(3); mockView.SendOperatorPressed(Operator.Add); Assert.AreEqual("3", mockView.Display); mockView.SendModifierPressed(Modifier.OpenParen); Assert.AreEqual("0", mockView.Display); mockView.SendNumberPressed(4); Assert.AreEqual("4", mockView.Display); mockView.SendOperatorPressed(Operator.Add); Assert.AreEqual("4", mockView.Display); mockView.SendNumberPressed(2); Assert.AreEqual("2", mockView.Display); mockView.SendModifierPressed(Modifier.ClosedParen); Assert.AreEqual("6", mockView.Display); mockView.SendModifierPressed(Modifier.Equal); Assert.AreEqual("9", mockView.Display); }
public void TestSimpleParens() // 3+(3/2) = { var mockView = new MockView(); var controller = new CalculatorController(mockView); mockView.SendNumberPressed(3); mockView.SendOperatorPressed(Operator.Add); mockView.SendModifierPressed(Modifier.OpenParen); mockView.SendNumberPressed(3); mockView.SendOperatorPressed(Operator.Divide); mockView.SendNumberPressed(2); mockView.SendModifierPressed(Modifier.ClosedParen); mockView.SendModifierPressed(Modifier.Equal); Assert.AreEqual("4.5", mockView.Display); }
public void TestEntryAfterEqual() { var mockView = new MockView(); var controller = new CalculatorController(mockView); mockView.SendNumberPressed(4); mockView.SendOperatorPressed(Operator.Subtract); mockView.SendNumberPressed(5); mockView.SendModifierPressed(Modifier.Equal); Assert.AreEqual("-1", mockView.Display); mockView.SendOperatorPressed(Operator.Add); mockView.SendNumberPressed(4); mockView.SendOperatorPressed(Operator.Subtract); mockView.SendNumberPressed(5); mockView.SendModifierPressed(Modifier.Equal); Assert.AreEqual("-2", mockView.Display); }
public void TestClear() { var mockView = new MockView(); var controller = new CalculatorController(mockView); mockView.SendNumberPressed(3); mockView.SendOperatorPressed(Operator.Add); mockView.SendModifierPressed(Modifier.Clear); Assert.AreEqual("", mockView.Display); //test functionality of calculator after clearing mockView.SendNumberPressed(4); mockView.SendOperatorPressed(Operator.Subtract); mockView.SendNumberPressed(5); mockView.SendModifierPressed(Modifier.Equal); Assert.AreEqual("-1", mockView.Display); }
public void TestAdd() { var mockView = new MockView(); var controller = new CalculatorController(mockView); mockView.SendNumberPressed(0.33333333333); mockView.SendOperatorPressed(Operator.Add); mockView.SendNumberPressed(5); mockView.SendModifierPressed(Modifier.Equal); Assert.AreEqual("5.3333", mockView.Display); }
public void TestDivide() { var mockView = new MockView(); var controller = new CalculatorController(mockView); mockView.SendNumberPressed(5); mockView.SendOperatorPressed(Operator.Divide); mockView.SendNumberPressed(3); mockView.SendModifierPressed(Modifier.Equal); Assert.AreEqual("1.6667", mockView.Display); }
public void TestMultiply() { var mockView = new MockView(); var controller = new CalculatorController(mockView); mockView.SendNumberPressed(4); mockView.SendOperatorPressed(Operator.Multiply); mockView.SendNumberPressed(5); mockView.SendModifierPressed(Modifier.Equal); Assert.AreEqual("20", mockView.Display); }
public void TestInvert() { var mockView = new MockView(); var controller = new CalculatorController(mockView); mockView.SendNumberPressed(2); mockView.SendModifierPressed(Modifier.Invert); Assert.AreEqual("-2", mockView.Display); mockView.SendOperatorPressed(Operator.Add); mockView.SendNumberPressed(3); mockView.SendModifierPressed(Modifier.Equal); Assert.AreEqual("1", mockView.Display); mockView.SendModifierPressed(Modifier.Invert); Assert.AreEqual("-1", mockView.Display); }