public void CountBadLinesTest_GoodFormat_NotReturn() { var k = new RegexKoordinaty("11.1111,55.6666"); var usertext = k.CountBadLines(); var NewText = ""; Assert.AreEqual(NewText, usertext); }
static void Main(string[] args) { Console.WriteLine("По завершению ввода строк введите: end"); StringBuilder SB = new StringBuilder(); //StringBuilder userEnter = new StringBuilder(); //while(true) //{ // userEnter.Append(Console.ReadLine()); // if (userEnter.ToString()=="end") // { // break; // } // SB.AppendLine(userEnter.ToString()); // userEnter.Clear(); //} RegexKoordinaty k = new RegexKoordinaty(SB.ToString()); ///путь к экзэшнику Assembly asm = Assembly.GetExecutingAssembly(); string assemblyPath = new Uri(asm.EscapedCodeBase).LocalPath; ///путь к текстовому файлу k.Pathfile = Path.Combine(Path.GetDirectoryName(assemblyPath), "12.txt"); try { string NewText = k.AllUserTextNewFormat(); Console.WriteLine(NewText); } catch (FileNotFoundException e) { Console.WriteLine(e.Message + e.FileName); } try { string message = k.CountBadLines(); Console.WriteLine(message); } catch (FormatException) { Console.WriteLine("ВАЖНО!!! Не все строки имели правильный формат"); } catch (FileNotFoundException) { Console.WriteLine("ошибка к доступу файла"); } Console.ReadLine(); }
public void CountBadLines_BadFormat_Exception() { var k = new RegexKoordinaty("11.1111, 55.6666"); try { var ExceptionText = k.CountBadLines(); } catch (FormatException e) { StringAssert.Contains(e.Message, "1 строк имели неправильный формат. Вводите правильный формат везде"); } }
public void CountBadLines_FileNotExist_Exception() { var k = new RegexKoordinaty("11.1111, 55.6666"); k.Pathfile = @"d:\ASP\ASP\Task1\Consolka\bin\Release\13.txt"; try { var ExceptionText = k.CountBadLines(); } catch (FileNotFoundException e) { StringAssert.Contains(e.Message, "Файл не существует либо указан неверный путь"); } }
private void button_Click(object sender, RoutedEventArgs e) { TextRange pp = new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd); RegexKoordinaty k = new RegexKoordinaty(pp.Text); if (new TextRange(richTextBox.Document.ContentStart, richTextBox.Document.ContentEnd).Text.Length > 3) { FlowDocument myflow = new FlowDocument(); string newtext = k.AllUserTextNewFormat(); myflow.Blocks.Add(new Paragraph(new Run(newtext))); richTextBox1.Document = myflow; string warning = ""; FlowDocument myflow1 = new FlowDocument(); try { warning = k.CountBadLines(); } catch (FormatException) { } finally { myflow1.Blocks.Add(new Paragraph(new Run(warning))); richTextBox2.Document = myflow1; } } if (textBox.Text.Length > 2) { k.Pathfile = textBox.Text; string newtext1 = ""; try { newtext1 = k.AllUserTextNewFormat(); } catch (FileNotFoundException exf) { FlowDocument myflow4 = new FlowDocument(); myflow4.Blocks.Add(new Paragraph(new Run(exf.Message))); richTextBox2.Document = myflow4; } FlowDocument myflow2 = new FlowDocument(); myflow2.Blocks.Add(new Paragraph(new Run(newtext1))); richTextBox1.Document = myflow2; string warning1 = ""; FlowDocument myflow3 = new FlowDocument(); try { warning1 = k.CountBadLines(); } catch (FormatException) { } finally { myflow3.Blocks.Add(new Paragraph(new Run(warning1))); richTextBox2.Document = myflow3; } } }