示例#1
0
        static void Process(List <Makelaar> makelaars, string message)
        {
            var validMakelaars = makelaars?.Where(m => m.Id > 0);

            if (validMakelaars == null || validMakelaars.Count() == 0)
            {
                Console.WriteLine($"No result found for {message}.");
                return;
            }

            Console.WriteLine($"{validMakelaars.Count()} {message} found...");

            Console.WriteLine($"Showing Top 10 {message} in Amsterdam.");

            int i = 0;

            Console.WriteLine($"No.  Id   Name");

            var coreLogic = new TopMakelaarsOptimize();

            foreach (var mak in coreLogic.GetTopTen(validMakelaars))
            {
                Console.WriteLine($"{++i} {mak.Id} {mak.Name}");
            }
        }
        public void CheckForEmptyRecords()
        {
            var logic1 = new TopMakelaars();

            Assert.AreEqual(logic1.GetTopTen(new List <Makelaar>()).Count(), 0);

            var logic2 = new TopMakelaarsOptimize();

            Assert.AreEqual(logic2.GetTopTen(new List <Makelaar>()).Count(), 0);
        }
        public void CheckForNullValue()
        {
            var logic1 = new TopMakelaars();

            Assert.AreEqual(logic1.GetTopTen(null).Count(), 0);

            var logic2 = new TopMakelaarsOptimize();

            Assert.AreEqual(logic2.GetTopTen(null).Count(), 0);
        }
        public void CheckForLessThanTenRecords()
        {
            var testData = new TestData();

            var logic1 = new TopMakelaars();

            Assert.IsTrue(logic1.GetTopTen(testData.GetTestData(5)).Count() <= 5);

            var logic2 = new TopMakelaarsOptimize();

            Assert.IsTrue(logic2.GetTopTen(testData.GetTestData(5)).Count() <= 5);
        }
        public void PerformanceTest10Power6_Optimize()
        {
            var testData = new TestData();
            var data     = testData.GetTestData((int)Math.Pow(10, 6));

            var stopwatch = new Stopwatch();

            // Begin timing
            stopwatch.Start();

            var logic = new TopMakelaarsOptimize();
            var ans   = logic.GetTopTen(data);

            stopwatch.Stop();

            Assert.IsTrue(stopwatch.ElapsedMilliseconds <= m_executionTimeLimitinMilliseconds);
        }