private void button1_Click(object sender, EventArgs e) { try { ControlCommand commander = new ControlCommand(new DevideCommand(tbCommand.Text)); if (commander.GetFinalPositionRobot != null) { foreach (var el in commander.GetFinalPositionRobot) { tbCommand.Text += String.Format("{0}: {1}", el.Key, el.Value); } } } catch (RootApplicationException exception) { tbCommand.Text += "\r\n" + exception.Message; if (exception.Data != null) { foreach (DictionaryEntry el in exception.Data) { tbCommand.Text += "\r\n" + String.Format("{0}: {1}", el.Key, el.Value); } } } catch (ApplicationException) { tbCommand.Text += "\r\nНе известная ошибка"; //tbCommand.Text += "\r\n" + exceptionUser.TargetSite; //tbCommand.Text += "\r\n" + exceptionUser.Source; //tbCommand.Text += "\r\n" + exceptionUser.StackTrace; //обработать исключение для которого не предуспотренна логика обработки и записать в файл для дальнейшего рассмотрения //:todo } }
public void ControlCommand() { var inputStringCommand = new[] { "5 5\r\n1 2 N\r\nLMLMLMLMM\r\n", "5 5\r\n1 2 N\r\nLMLMLMLMM\r\n1 2 N\r\nLMLMLMLMM\r\n", "5 5\r\n1 2 N\r\nLMLMLMLMM\r\n1 -2 N\r\nLMLMLMLMM\r\n" }; var outputValues = new IComparable[] { 1, 2, "ERROR" }; for(int i = 0; i < inputStringCommand.Length; i++) { try { var controlCommand = new ControlCommand(new DevideCommand(inputStringCommand[i])); Assert.AreEqual(controlCommand.GetFinalPositionRobot.Count, outputValues[i]); } catch (CommandControlException exception) { Assert.AreEqual("Строка не корректна.", exception.Message); } } }
public Form1() { InitializeComponent(); try { ControlCommand commander = new ControlCommand(new DevideCommand("5 5\r\n1 2 N\r\nLMLMLMLMM\r\n")); if (commander.GetFinalPositionRobot != null) { foreach (var el in commander.GetFinalPositionRobot) { tbCommand.Text += String.Format("{0}: {1}", el.Key, el.Value); } } } catch (RootApplicationException exception) { tbCommand.Text = exception.Message; } }