Exemplo n.º 1
0
        public async Task TestRampingDown()
        {
            var operationService  = new AsyncOperationService();
            var targetTemperature = new Value <Unit.Temperature>(3.0, Unit.Temperature.TemperatureInDegC);
            var rampRate          = new Value <Unit.TemperatureRate>(2.5, Unit.TemperatureRate.TemperatureRateInDegCPerMinute);
            var minBand           = new Value <Unit.Temperature>(targetTemperature.Number - 1, Unit.Temperature.TemperatureInDegC);
            var maxBand           = new Value <Unit.Temperature>(targetTemperature.Number + 1, Unit.Temperature.TemperatureInDegC);
            var band = new ReadOnlyRange <Unit.Temperature>(minBand, maxBand);
            var time = TimeSpan.FromMinutes(5);
            await operationService.RampingDownAsync(targetTemperature, rampRate, band, time);

            var currentTemp = operationService.GetCurrentTemperature().Number;

            Assert.AreEqual(3.0, currentTemp);
        }
Exemplo n.º 2
0
        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 Value <Unit.Temperature> GetCurrentTemperature()
        {
            var result = _operationService.GetCurrentTemperature();

            return(result);
        }