private static void RunTests(List <Product> products, int countToExtract, int repetitions) { for (int i = 0; i < repetitions; i++) { decimal min = ProductsGenerator.GetPrice(ProductsGenerator.MIN_PRICE, ProductsGenerator.MAX_PRICE); decimal max = ProductsGenerator.GetPrice(ProductsGenerator.MIN_PRICE, ProductsGenerator.MAX_PRICE); if (min > max) { decimal temp = min; min = max; max = temp; } ProductsInRange(products, min, max, countToExtract); } }
private static void Main() { helper.ConsoleMio.Setup(); helper.ConsoleMio.PrintHeading("Task 2 Find Top Products In A Price Range "); var timer = new Stopwatch(); helper.ConsoleMio.WriteLine("Generating data...", ConsoleColor.DarkCyan); timer.Start(); ProductsGenerator.ReadDataFromJson(); List <Product> products = ProductsGenerator.GenerateProducts(500000); products.Sort(); timer.Stop(); helper.ConsoleMio.WriteLine("Generated in: {0}", ConsoleColor.DarkGreen, timer.Elapsed); do { var menu = helper.ConsoleMio.CreateMenu(new List <string>()); menu.AddItem("Test") .AddItem("Manual Test"); string selected = menu.DisplayMenu(ConsoleColor.DarkCyan, ConsoleColor.White); if (selected == "Test") { timer.Restart(); RunTests(products, 20, 10000); timer.Stop(); helper.ConsoleMio.Write("Job finished! Elapsed Time: ", ConsoleColor.DarkGreen) .WriteLine(timer.Elapsed.ToString(), ConsoleColor.Gray); } else { RunManualTest(products); helper.ConsoleMio.WriteLine( "Tests ended if no asset message poped out everithing works correct", ConsoleColor.DarkGreen); } helper.ConsoleMio.WriteLine( "Da izlyaza malko? Press Esc to exit any other to repeat...", ConsoleColor.DarkCyan); }while (Console.ReadKey(true).Key != ConsoleKey.Escape); }