public void AddOperationWithoutTrackingId() { int[] numbers = { 2, 2 }; var result = _mathService.Add(numbers); Assert.IsNotNull(result); Assert.AreEqual(result, 4); }
protected void _add_Command(object sender, CommandEventArgs e) { if (int.TryParse(_op1.Text, out a) && int.TryParse(_op2.Text, out b)) { IMathService service = (IMathService)RemotingHelper.GetObject(typeof(IMathService)); _addResult.Text = service.Add(a, b).ToString(); } }
private void button1_Click(object sender, EventArgs e) { MathServiceLibrary.MyNumbers obj = new MathServiceLibrary.MyNumbers(); obj.Number1 = Convert.ToInt32(textBox1.Text); obj.Number2 = Convert.ToInt32(textBox2.Text); textBox3.Text = channel.Add(obj).ToString(); }
private void button5_Click(object sender, EventArgs e) { MyNumbers obj = new MyNumbers(); obj.Number1 = Convert.ToInt32(textBox1.Text); obj.Number2 = Convert.ToInt32(textBox2.Text); textBox3.Text = nettcpChannel.Add(obj).ToString(); }
public async Task <IActionResult> Add( [HttpTrigger(AuthorizationLevel.Function, "post", Route = "add/{addend1}/{addend2}")] HttpRequestMessage req, int addend1, int addend2, ILogger log) { log.LogInformation($"Executing function: {nameof(Add)}"); return(await Task.FromResult(new OkObjectResult(mathService.Add(addend1, addend2)))); }
public double Hypotense(double a, double b) { var aSquared = _mathService.Squared(a); var bSquared = _mathService.Squared(b); var cSquared = _mathService.Add(aSquared, bSquared); return(_mathService.SquareRoot(cSquared)); }
private void btnAdd_Click(object sender, EventArgs e) { var myNum = new MyNumbers { Number1 = int.Parse(txtNumber1.Text), Number2 = int.Parse(txtNumber2.Text) }; txtResult.Text = _channel.Add(myNum).ToString(); }
private void button_add_Click(object sender, RoutedEventArgs e) { int firstNum = Convert.ToInt32(text_first_num.Text); int secNum = Convert.ToInt32(text_second_num.Text); IMathService mathHandler = RequestFactory.GetMathServiceHandler(); int ans = mathHandler.Add(firstNum, secNum); text_answ.Text = Convert.ToString(ans); }
public void Add_AddingTwuNumbers_ReturnsSum() { //Arrange decimal expected = 4; decimal num1 = 2; decimal num2 = 2; //Act decimal myAnswer = mathService.Add(num1, num2); //Assert Assert.AreEqual(expected, myAnswer); }
private void BtnCompute_Click(object sender, System.EventArgs e) { num1 = decimal.Parse(editNum1.Text); num2 = decimal.Parse(editNum2.Text); alert.SetTitle("Answer"); if (num1.Equals(null)) { editNum1.SetError("Num1 Cannot be Empty", null); } if (num2.Equals(null)) { editNum1.SetError("Num2 Cannot be Empty", null); } switch (selectedOperation) { case "Add": output = mathService.Add(num1, num2); //Display Alert alert.SetMessage("The sum is " + output); alert.Show(); break; case "Subtract": output = mathService.Subtract(num1, num2); //Display Alert alert.SetMessage("The difference is " + output); alert.Show(); break; case "Multiply": output = mathService.Multiply(num1, num2); //Display Alert alert.SetMessage("The product is " + output); alert.Show(); break; case "Divide": output = mathService.Divide(num1, num2); //Display Alert alert.SetMessage("The quotient is " + output); alert.Show(); break; } }
private void button1_Click(object sender, EventArgs e) { MyNumbers obj = new MyNumbers(); obj.Number1 = Convert.ToInt32(textBox1.Text); obj.Number2 = Convert.ToInt32(textBox2.Text); try { textBox3.Text = channel.Add(obj).ToString(); } catch (Exception) { Console.WriteLine("exception "); } }
public override async Task <long[][]> Run(IMathService MathService, long[] InputValues, long[] StepValues) { // Create output array. var outputValues = new long[InputValues.Length][]; for (var index = 0; index < outputValues.Length; index++) { outputValues[index] = new long[StepValues.Length]; } // To establish baseline performance, call math service methods sequentially. for (var index = 0; index < InputValues.Length; index++) { var inputValue = InputValues[index]; var stepValue = StepValues[0]; // Step 1 : Power var outputValue = await MathService.Power(inputValue, stepValue); outputValues[index][0] = outputValue; inputValue = outputValue; // Step 2 : Add stepValue = StepValues[1]; outputValue = await MathService.Add(inputValue, stepValue); outputValues[index][1] = outputValue; inputValue = outputValue; // Step 3 : Multiply stepValue = StepValues[2]; outputValue = await MathService.Multiply(inputValue, stepValue); outputValues[index][2] = outputValue; inputValue = outputValue; // Step 4 : Modulo stepValue = StepValues[3]; outputValue = await MathService.Modulo(inputValue, stepValue); outputValues[index][3] = outputValue; // Display values. DisplayValues(InputValues, StepValues, outputValues); } return(outputValues); }
public IActionResult Add([FromBody] AddRequest addRequest) { Log.Debug("Add"); if (!ModelState.IsValid) { return(GetError(StatusCodes.Status400BadRequest)); } try { var result = _mathService.Add(addRequest.Addends, Request.GetHeader(CalculatorServiceConstants.EvilTrackingHeader)); if (result.HasValue) { return(Ok(new AddResponse(result.Value))); } } catch (Exception ex) { Log.Error(ex.Message); } return(GetError(StatusCodes.Status500InternalServerError)); }
public double Add(double a, double b) { return(_mathService.Add(a, b)); }
private async void AddButtonClicked(object sender, System.EventArgs e) { var result = _mathService.Add(Convert.ToInt32(txtNumber01.Text), Convert.ToInt32(txtNumber02.Text)); await DisplayAlert("Add", $"Result: {result}", "Ok"); }
public IActionResult Add(CalcuatorModel calcuatorRequest) { return(Ok(_mathService.Add(calcuatorRequest.X, calcuatorRequest.Y))); }
public IActionResult Post(int firstNumber, int secondNumber) => Ok(_mathService.Add(firstNumber, secondNumber));
public double Add(double a, double b) { return(_channel.Add(a, b)); }
public IActionResult Add(int a, int b, [FromServices] IMathService ms) { return(Ok(ms.Add(a, b))); }
public override async Task <long[][]> Run(IMathService MathService, long[] InputValues, long[] StepValues) { // Create output array. var outputValues = new long[InputValues.Length][]; for (var index = 0; index < outputValues.Length; index++) { outputValues[index] = new long[StepValues.Length]; } // Step 1 : Power // Call service method asynchronously. var step1Tasks = new HashSet <Task <(int Index, long OutputValue)> >(); for (var index = 0; index < InputValues.Length; index++) { var localIndex = index; // Prevent lambda from capturing last index value of containing for loop. var inputValue = InputValues[index]; var stepValue = StepValues[0]; // Capture task. Don't block by awaiting. step1Tasks.Add(AsyncHelper.MaterializeTask(async() => { var outputValue = await MathService.Power(inputValue, stepValue); return(localIndex, outputValue); })); } // Step 2 : Add // Process step 1 results as they arrive. Use result of step 1 to call step 2 service method asynchronously. var step2Tasks = new HashSet <Task <(int Index, long OutputValue)> >(); while (step1Tasks.Count > 0) { if (step1Tasks.Count == 0) { continue; // Avoid exception caused by awaiting empty collection in next line. } var step1Task = await Task.WhenAny(step1Tasks); var(index, outputValue) = await step1Task; // Network or internal service method exceptions may occur here. Ignore in this demo program. outputValues[index][0] = outputValue; step1Tasks.Remove(step1Task); // Remove from task collection so we don't consume it again. var inputValue = outputValue; var stepValue = StepValues[1]; // Capture task. Don't block by awaiting. step2Tasks.Add(AsyncHelper.MaterializeTask(async() => { outputValue = await MathService.Add(inputValue, stepValue); return(index, outputValue); })); } DisplayValues(InputValues, StepValues, outputValues); // Step 3 : Multiply // Process step 2 results as they arrive. Use result of step 2 to call step 3 service method asynchronously. var step3Tasks = new HashSet <Task <(int Index, long OutputValue)> >(); while ((step1Tasks.Count + step2Tasks.Count) > 0) { if (step2Tasks.Count == 0) { continue; // Avoid exception caused by awaiting empty collection in next line. } var step2Task = await Task.WhenAny(step2Tasks); var(index, outputValue) = await step2Task; // Network or internal service method exceptions may occur here. Ignore in this demo program. outputValues[index][1] = outputValue; step2Tasks.Remove(step2Task); // Remove from task collection so we don't consume it again. var inputValue = outputValue; var stepValue = StepValues[2]; // Capture task. Don't block by awaiting. step3Tasks.Add(AsyncHelper.MaterializeTask(async() => { outputValue = await MathService.Multiply(inputValue, stepValue); return(index, outputValue); })); } DisplayValues(InputValues, StepValues, outputValues); // Step 4 : Modulo // Process step 3 results as they arrive. Use result of step 3 to call step 4 service method asynchronously. var step4Tasks = new HashSet <Task <(int Index, long OutputValue)> >(); while ((step2Tasks.Count + step3Tasks.Count) > 0) { if (step3Tasks.Count == 0) { continue; // Avoid exception caused by awaiting empty collection in next line. } var step3Task = await Task.WhenAny(step3Tasks); var(index, outputValue) = await step3Task; // Network or internal service method exceptions may occur here. Ignore in this demo program. outputValues[index][2] = outputValue; step3Tasks.Remove(step3Task); // Remove from task collection so we don't consume it again. var inputValue = outputValue; var stepValue = StepValues[3]; // Capture task. Don't block by awaiting. step4Tasks.Add(AsyncHelper.MaterializeTask(async() => { outputValue = await MathService.Modulo(inputValue, stepValue); return(index, outputValue); })); } DisplayValues(InputValues, StepValues, outputValues); // Final Results while ((step3Tasks.Count + step4Tasks.Count) > 0) { if (step4Tasks.Count == 0) { continue; // Avoid exception caused by awaiting empty collection in next line. } var step4Task = await Task.WhenAny(step4Tasks); var(index, outputValue) = await step4Task; // Network or internal service method exceptions may occur here. Ignore in this demo program. outputValues[index][3] = outputValue; step4Tasks.Remove(step4Task); // Remove from task collection so we don't consume it again. } DisplayValues(InputValues, StepValues, outputValues); return(outputValues); }
public int Add(int x, int y) => _mathService.Add(x, y);
public void WhenTheTwoNumbersAreAdded() { actualValue = mathService.Add(num1, num2); }
public int Add10(int x) { return(_mathService.Add(x, 10)); }