public void UpdateFromString_InvalidUpdateString_ObjectUpdated() { BatteryCell bc = new BatteryCell(4) { Voltage = 3.5f }; string updateString; updateString = "<BC;4,3.6>"; bc.UpdateFromString(updateString); Assert.AreEqual(3.6f, bc.Voltage); }
private void HandleBatteryCellWarningVoltage(BatteryCell cell) { if (!this.Dispatcher.HasShutdownStarted && !this.Dispatcher.HasShutdownFinished) { this.Dispatcher.Invoke((Action)(() => { var cellBar = this.FindName("cellBar" + cell.CellID) as ProgressBar; cellBar.Foreground = Brushes.OrangeRed; var cellPanel = this.FindName("cellPanel" + cell.CellID) as StackPanel; cellPanel.ToolTip = "This battery cell is currently operating at a non-ideal voltage."; })); } }
private void HandleBatteryCellUnderVoltage(BatteryCell cell) { if (!this.Dispatcher.HasShutdownStarted && !this.Dispatcher.HasShutdownFinished) { this.Dispatcher.Invoke((Action)(() => { var cellBar = this.FindName("cellBar" + cell.CellID) as ProgressBar; cellBar.Foreground = Brushes.DarkRed; var cellPanel = this.FindName("cellPanel" + cell.CellID) as StackPanel; cellPanel.ToolTip = "This battery cell is currently experiencing under voltage."; })); } }
private void HandleBatteryCellNormalVoltage(BatteryCell cell) { if (!this.Dispatcher.HasShutdownStarted && !this.Dispatcher.HasShutdownFinished) { this.Dispatcher.Invoke((Action)(() => { var cellBar = this.FindName("cellBar" + cell.CellID) as ProgressBar; cellBar.Foreground = Brushes.Lime; var cellPanel = this.FindName("cellPanel" + cell.CellID) as StackPanel; cellPanel.ToolTip = null; })); } }
public void UpdateFromString_InvalidUpdateString_ThrowException() { BatteryCell bc = new BatteryCell(2); string updateString; updateString = "<>"; Assert.Throws<InvalidUpdateStringException>(() => bc.UpdateFromString(updateString)); updateString = "<B;23,45.2>"; Assert.Throws<InvalidUpdateStringException>(() => bc.UpdateFromString(updateString)); updateString = "<B,1,4>"; Assert.Throws<InvalidUpdateStringException>(() => bc.UpdateFromString(updateString)); updateString = "<B;3,45.1235>"; Assert.Throws<InvalidUpdateStringException>(() => bc.UpdateFromString(updateString)); updateString = "<B;,12>"; Assert.Throws<InvalidUpdateStringException>(() => bc.UpdateFromString(updateString)); }
public void GetUpdateString_ValidUpdateStringGenerated_ValidUpdateStringReturned() { BatteryCell bc = new BatteryCell(3) { Voltage = 3.2f }; Assert.AreEqual(String.Format("<BC;{0},{1}>", bc.CellID, bc.Voltage), bc.GetUpdateString()); }