public void CalculatorTests() { var calculator = new Divider(); double actual = calculator.Calculate(4, 2); Assert.AreEqual(2, actual: actual); }
public void Calculate() { Divider calculator = new Divider(); double result = calculator.Calculate(10, 5); Assert.AreEqual(2, result); }
public void DividerTest() { Divider calculator = new Divider(); double result = calculator.Calculate(6, 3); Assert.AreEqual(2, result); }
public void CalculateTestByZero() { ITwoArgumentsCalculator calculator = new Divider(); double result = calculator.Calculate(4, 2); //Assert.Throws<>(() => //calculator.Calculate()); }
public void CalculateTest() { ITwoArgumentsCalculator calculator = new Divider(); double result = calculator.Calculate(4, 2); Assert.AreEqual(2, result); }
public void CalculateTest( double firstValue, double secondValue, double expected) { var calculator = new Divider(); var actualResult = calculator.Calculate(firstValue, secondValue); Assert.AreEqual(expected, actualResult); }
public void TestComplex() { IExpression e = new Divider( new Multiplier( new Negate(new Constant(5.0)), new Divider(new Constant(9.0), new Constant(6.0)) ), new Adder( new Constant(7.0), new Subtracter(new Constant(2.0), new Constant(1.5)) ) ); Assert.AreEqual(-1, e.Calculate()); }
public ActionResult <Adder> Post([FromBody] CalculatorRequest calculatorRequest) { CalculatorOperatorBase calculator; switch (calculatorRequest.CalculatorOperatorType) { case CalculatorOperatorTypeEnum.Adder: { calculator = new Adder(calculatorRequest.LeftVal, calculatorRequest.RightVal); break; } case CalculatorOperatorTypeEnum.Substracter: { calculator = new Substracter(calculatorRequest.LeftVal, calculatorRequest.RightVal); break; } case CalculatorOperatorTypeEnum.Multiplier: { calculator = new Multiplier(calculatorRequest.LeftVal, calculatorRequest.RightVal); break; } case CalculatorOperatorTypeEnum.Divider: { calculator = new Divider(calculatorRequest.LeftVal, calculatorRequest.RightVal); break; } default: { return(BadRequest("Invalid CalculatorOperatorType")); } } calculator.Calculate(); var calculatorResponse = new CalculatorResponse { Result = calculator.Result }; return(Ok(calculatorResponse)); }
public void TestDivider() { IExpression e = new Divider(new Constant(5.0), new Constant(2.0)); Assert.AreEqual(2.5, e.Calculate()); }
public void ExceptionTest() { var calculator = new Divider(); Assert.Throws <Exception>(() => calculator.Calculate(3, 0)); }
public void NegativeCalculateTest() { var calculator = new Divider(); Assert.Throws <System.Exception>(() => calculator.Calculate(2, 0)); }
public void CalculateTestExceptionTest() { ITwoArgumentsCalculator calculator = new Divider(); Assert.Throws <Exception>(() => calculator.Calculate(2, 0)); }