public void ManualEntryThrowsExceptionForEmptyString() { var entry = new NumberEntry(); string testData = string.Empty; entry.ManualEntry(testData); }
public void ManualEntryReturnsCommaRemovedList() { var entry = new NumberEntry(); string testData = "100,32,45,64,24"; var decimalList = entry.ManualEntry(testData); Assert.AreEqual(new List<decimal>() { 100m, 32m, 45m, 64m, 24m }, decimalList); }
static void Main(string[] args) { var printer = new ResultPrinter(); var numbers = new List<decimal>(); var input = new NumberEntry(); while (true) { Choice = AskUserForInput().ToUpper(); if (Choice != "I" && Choice != "F") { Console.WriteLine("Invalid input. Try again."); } if (Choice == "I") { // read numbers manually Console.Write("Enter a set of numbers (separated by commas): "); string numberSet = Console.ReadLine(); var decimals = input.ManualEntry(numberSet); foreach (decimal d in decimals) { numbers.Add(d); } printer.PrintResults(numbers); break; } do { string filename = @"C:\Users\apprentice\Documents\Visual Studio 2012\Projects\MeanMedianAndMode\MeanMedianAndMode.Operations\bin\Debug\Numbers.txt"; //Console.Write("Enter filename: "); //string filename = path + Console.ReadLine(); if (!File.Exists(filename)) Console.WriteLine("File does not exist. Try again!"); else { var numbersAsString = input.ReadNumbersFromFile(filename); foreach (string num in numbersAsString) { numbers.Add(decimal.Parse(num)); } printer.PrintResults(numbers); break; } } while (true); } Console.ReadLine(); }