Ejemplo n.º 1
0
        public static void Main(string[] args)
        {
            var path = "../../../TextFiles/TextFile1.txt";

            if (File.Exists(path))
            {
                var service = new HistogramService();
                try
                {
                    var results = service.ProcessFile(path);

                    foreach (var model in results)
                    {
                        Console.WriteLine($"\"{model.Key}\" \t : {model.Value}");
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine($"Error: {e.Message}");
                }
            }
            else
            {
                Console.WriteLine($"ERROR: File does not exist at {path}");
            }
            Console.ReadLine();
        }
Ejemplo n.º 2
0
        public void TestLengthOfResults()
        {
            var sut      = new HistogramService();
            var testFile = "../../../TextFiles/TextFile1.txt";
            var results  = sut.ProcessFile(testFile).Count;

            Assert.AreEqual(12, results);
        }
Ejemplo n.º 3
0
        public void TestValueOfResults()
        {
            var sut      = new HistogramService();
            var testFile = "../../../TextFiles/TextFile1.txt";
            var results  = sut.ProcessFile(testFile).Take(1).Select(d => d.Value).First();

            Assert.AreEqual(2, results);
        }