public void BreakText_GetsAndBreaksTextFromFile_BreakesTextCorrectly() { var actualResult = new List <string>(); var maxLineLength = 6; var expectedResult = new List <string> { "Words", "can be", "like", "bricks", "- bad", "for", "your", "teeth." }; if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } if (!File.Exists(path)) { File.Create(path).Close(); } File.AppendAllText(path, text); textHandler.BreakText(path, maxLineLength, outputPath); Assert.IsTrue(File.Exists(outputPath)); using (var stream = new StreamReader(outputPath)) { while (!stream.EndOfStream) { actualResult.Add(stream.ReadLine()); } } AssertListUniformity(expectedResult, actualResult); }
private void btnBreak_Click(object sender, RoutedEventArgs e) { int maxLength; if (string.IsNullOrEmpty(txtInputFilePath.Text) || string.IsNullOrEmpty(txtLength.Text) || !int.TryParse(txtLength.Text, out maxLength)) { lbInputResult.Items.Clear(); lbInputResult.Items.Add("SELECT A FILE TO READ FROM AND ENTER MAX LINE LENGTH"); return; } GetOriginalText(); var result = textHandlerService.BreakText(txtInputFilePath.Text, maxLength, txtOutputFilePath.Text); lbOutputResult.Items.Clear(); result.ForEach(x => lbOutputResult.Items.Add($"[L{x.Length}] {x}")); }