/// <summary> /// Remove a subsystem from the serial number. /// </summary> private void On_RemoveSubsystemCommand() { if (_SerialNumber.SubSystemsList.Count > 0) { // Remove the last subsystem in the serial number Subsystem ss = _SerialNumber.SubSystemsList.Last(); _SerialNumber.RemoveSubsystem(ss); // Add the Subsystem type back to the list RTI.SubsystemList.SubsystemCodeDesc subsysDesc = new RTI.SubsystemList.SubsystemCodeDesc(ss.Code, Subsystem.DescString(ss.Code)); if (!ListOfSubsystems.Contains(subsysDesc)) { ListOfSubsystems.Add(subsysDesc); // Set something new to the selected subsystem if (ListOfSubsystems.Count > 0) { SelectedSubsystem = ListOfSubsystems.First(); } } } // Update the Subsystem and Serial number string this.NotifyOfPropertyChange(() => this.Subsystems); this.NotifyOfPropertyChange(() => this.SerialNumStr); //// Call this to update the button if should be disabled //((DelegateCommand<object>)AddSubsystemCommand).RaiseCanExecuteChanged(); //((DelegateCommand<object>)RemoveSubsystemCommand).RaiseCanExecuteChanged(); }
public void TestRemoveSubsystemWrongIndex() { // Create a serial number string serialStr = "01345600000000000000000000000001"; SerialNumber serial = new SerialNumber(serialStr); Subsystem ss = new Subsystem("4", 4); serial.RemoveSubsystem(ss); Assert.AreEqual(3, serial.SubSystemsList.Count, "Subsystem count is incorrect."); // Subsystem type 3 Subsystem ss0 = new Subsystem("3", 0); Assert.AreEqual(ss0, serial.SubSystemsList[0], string.Format("Subsystems do not match {0} {1}", ss0.ToString(), serial.SubSystemsList[0].ToString())); // Subsystem type 2 Subsystem ss2 = new Subsystem("5", 1); Assert.AreEqual(ss2, serial.SubSystemsList[1], string.Format("Subsystems do not match {0} {1}", ss2.ToString(), serial.SubSystemsList[1].ToString())); }
public void TestRemoveSubsystemWrongIndex() { // Create a serial number string serialStr = "01345600000000000000000000000001"; SerialNumber serial = new SerialNumber(serialStr); Subsystem ss = new Subsystem("4", 4); serial.RemoveSubsystem(ss); Assert.AreEqual(3, serial.SubSystemsList.Count, "Subsystem count is incorrect."); // Subsystem type 3 Subsystem ss0 = new Subsystem("3", 0); Assert.AreEqual(ss0, serial.SubSystemsList[0], string.Format("Subsystems do not match {0} {1}", ss0.ToString(), serial.SubSystemsList[0].ToString())); // Subsystem type 2 Subsystem ss2 = new Subsystem("5", 1); Assert.AreEqual(ss2, serial.SubSystemsList[1], string.Format("Subsystems do not match {0} {1}", ss2.ToString(), serial.SubSystemsList[1].ToString())); }