Пример #1
0
 public void VerifyThatCorrectlyCreatedMessagesResultInValidToStringOutput()
 {
     string expected = "R**";
     string actualUsingBytes = new ModuleStateRequest('*', 0).ToString();
     string actualUsingEnums = new ModuleStateRequest(House.X, Unit.X).ToString();
     Assert.AreEqual(expected, actualUsingBytes);
     Assert.AreEqual(expected, actualUsingEnums);
     for (var house = 'A'; house <= 'P'; house++ )
     {
         for(byte unit = 0; unit <= 16; unit++)
         {
             expected = "R" + house + (unit == 0 ? "*" : (unit - 1).ToString("X"));
             actualUsingBytes = new ModuleStateRequest(house, unit).ToString();
             actualUsingEnums = new ModuleStateRequest((House)house, (Unit)(unit - 1)).ToString();
             Assert.AreEqual(expected, actualUsingBytes);
             Assert.AreEqual(expected, actualUsingEnums);
         }
     }
 }
Пример #2
0
 private void btnGetState_Click(object sender, RoutedEventArgs e)
 {
     cbxUpdateUiOnStateRequest.IsChecked = true;
     try
     {
         ModuleStateRequest message = new ModuleStateRequest(House, Unit);
         _serial.SendMessage(message);
         txtSentLog.Text += message + Environment.NewLine;
         txtSentLog.ScrollToEnd();
     }
     catch (Exception ex)
     {
         MessageBox.Show("An unexpected error occured. " + ex.Message);
     }
 }