public void TestAllLogic_ShouldReturnAllResults() { int number1 = 6; int number2 = 3; Numbers requestAdd = new Numbers(number1, number2, "Add"); Numbers requestSub = new Numbers(number1, number2, "Subtract"); Numbers requestMulty = new Numbers(number1, number2, "Multypile"); Numbers requestDiv = new Numbers(number1, number2, "Divide"); int AddResult = _chain.Calculate(requestAdd); int SubstractResult = _chain.Calculate(requestSub); int MultyResult = _chain.Calculate(requestMulty); int DivResult = _chain.Calculate(requestDiv); Assert.AreEqual(9, AddResult); Assert.AreEqual(3, SubstractResult); Assert.AreEqual(18, MultyResult); Assert.AreEqual(2, DivResult); }
public double?Calculate(Command command) { if (command.Operation == "+") { return(command.Number1 + command.Number2); } else { return(_next?.Calculate(command)); } }
public double Calculate(Numbers request) { if (request.Operation.ToLower().Equals("multiply")) { return(request.Number1 * request.Number2); } else { return(_nextInChain.Calculate(request)); } }
public void Calculate(Number number) { if (number.CalcWanted == "Add") { Console.WriteLine("ADD"); } else { _nextChain.Calculate(number); } }
public double?Calculate(Command command) { if (command.Operation == "**") { return(Math.Pow(command.Number1, command.Number2)); } else { return(_next?.Calculate(command)); } }
public void Calculate(Numbers numbers) { if (numbers.Action.Equals("mult")) { int result = numbers.Number1 * numbers.Number2; Console.WriteLine($"{numbers.Number1} * {numbers.Number2} = {result}"); } else { _nextChain.Calculate(numbers); } }
public int Calculate(Numbers request) { if (CanDo(request)) { return(InnerCalculate(request)); } else if (_nextChain != null) { return(_nextChain.Calculate(request)); } else { throw new MatchingLogicNotFoundException(); } }