Example #1
0
        public void ReadTemperature_IsDoubleWithTrailingStar_ReturnsTemperature()
        {
            //Act
            var temperature = TemperatureReader.ReadTemperature("97.1*");

            //Assert
            temperature.Should().Be(97.1);
        }
Example #2
0
        public void ReadTemperature_IsDoubleWithWhiteSpace_ReturnsTemperature()
        {
            //Act
            var temperature = TemperatureReader.ReadTemperature(" 88 ");

            //Assert
            temperature.Should().Be(88);
        }
Example #3
0
        public void ReadTemperature_IsNullOrWhiteSpace_ThrowArgumentException(string temperatureString)
        {
            //Act
            Action action = () => TemperatureReader.ReadTemperature(temperatureString);

            //Assert
            action.Should().Throw <ArgumentException>();
        }
Example #4
0
 public MainForm()
 {
     InitializeComponent();
     SetConnectionState(false);
     _timer             = new Timer();
     _timer.Interval    = 500;
     _timer.Tick       += Timer_Tick;
     _temperatureReader = new TemperatureReader();
 }
        private async void TimerElapsed(object sender, ElapsedEventArgs e)
        {
            try
            {
                var currentTemperature = TemperatureReader.GetCurrentTemperature();
                await _hubContext.Clients.All.SendAsync("UpdateTemperature", currentTemperature);

                if (currentTemperature.Temperature > 65.0 && FanController != null)
                {
                    FanController.On();
                }
                else if (currentTemperature.Temperature <= 65.0 && FanController != null)
                {
                    FanController.Off();
                }
            }
            catch (Exception exception)
            {
                Console.WriteLine(exception);
            }
        }