/// <summary> /// Reads a file and starts to format the text of that file /// </summary> /// <param name="filePath"></param> private static void ShowFormattedText(string filePath) { try { if (!File.Exists(filePath)) { return; } var inputText = File.ReadAllText(filePath); var textManipulate = new TextManipulate(); var frequencyList = textManipulate.GetFormattedData(inputText); if (frequencyList == null) { return; } foreach (var item in frequencyList) { Console.WriteLine($"{item.WorkCount}: {item.Word}"); Console.WriteLine(); } } catch (Exception ex) { var exception = ex.ToString(); //TODO:Log exception using a custom exception handler } }
public void GetFormattedData_NullAsInput() { //Arrange var processInput = new TextManipulate(); //Act var actual = processInput.GetFormattedData(null); //Assert //Exception expected }
public void GetFormattedData_CompareFirstItem() { //Arrange var processInput = new TextManipulate(); var inputText = "Go do that thing that you do so well"; var expected = "1: Go"; //Act var actual = processInput.GetFormattedData(inputText); //Assert Assert.AreEqual($"{actual[0].WorkCount}: {actual[0].Word}", expected); }
public void GetFormattedData_CountOfOutputItems() { //Arrange var processInput = new TextManipulate(); var inputText = "Go do that thing that you do so well"; var expectedCount = 7; //Act var actual = processInput.GetFormattedData(inputText); //Assert Assert.AreEqual(actual.Count, expectedCount); }