static void Main(string[] args) { #region Problem //Calculator calculator = new Calculator(); //calculator.Execute(1, 2, Operation.Sum); #endregion #region Solution Calculator calculator = new Sum(); calculator.Execute(1, 2); calculator = new Subtract(); calculator.Execute(5, 3); #endregion }
public async void ExecuteCalculatorSubtractRequest() { SubtractRequest request = new SubtractRequest() { intA = UnityEngine.Random.Range(-byte.MaxValue, byte.MaxValue), intB = UnityEngine.Random.Range(-byte.MaxValue, byte.MaxValue) }; SubtractResponse response = await Subtract.Execute(_calculatorClient, request); if (response != null) { _results.text = string.Format("{0} - {1} = {2}", request.intA, request.intB, response.Value) + Environment.NewLine; } }
public void SubtractExecute() { Subtract task = new Subtract(); task.BuildEngine = new MockBuild(); task.Numbers = new string[] { "5", "3" }; Assert.IsTrue(task.Execute(), "Execute Failed"); Assert.AreEqual("2", task.Result); task = new Subtract(); task.BuildEngine = new MockBuild(); task.Numbers = new string[] { "1.1", "2.2" }; Assert.IsTrue(task.Execute(), "Execute Failed"); Assert.AreEqual("-1.1", task.Result); }
public static Fraction Subtract(this Fraction a, Fraction b) { var op = new Subtract(); return(op.Execute(a, b)); }