public void TestCancelRamp() { var operationService = new AsyncOperationService(); var targetTemperature = new Value <Unit.Temperature>(69.56, Unit.Temperature.TemperatureInDegC); var rampRate = new Value <Unit.TemperatureRate>(2.5, Unit.TemperatureRate.TemperatureRateInDegCPerMinute); var minBand = new Value <Unit.Temperature>(targetTemperature.Number - 3, Unit.Temperature.TemperatureInDegC); var maxBand = new Value <Unit.Temperature>(targetTemperature.Number + 3, Unit.Temperature.TemperatureInDegC); var band = new ReadOnlyRange <Unit.Temperature>(minBand, maxBand); var time = TimeSpan.FromMinutes(5); Task.Run(async() => { await operationService.RampingDownAsync(targetTemperature, rampRate, band, time); }); operationService.CancelOperation(); Assert.IsFalse(operationService.GetOperationStatus()); Assert.AreNotEqual(69.56, operationService.GetCurrentTemperature()); }
public ActionResult CancelRamping() { var result = ""; try { _operationService.CancelOperation(); result = "Ramping has been canceled"; } catch (Exception e) { Console.WriteLine(e.Message); result = e.Message; } return(new ContentResult { Content = JsonConvert.SerializeObject(result), ContentType = "application/json" }); }