Example #1
0
 private void PrintMode(List<decimal> numbers)
 {
     try
     {
         var modeCalc = new ModeCalculator();
         var mode = modeCalc.CalculateMode(numbers);
         Console.WriteLine("Mode: {0}", mode);
     }
     catch (Exception)
     {
         Console.WriteLine("Mode: ERROR");
     }
 }
Example #2
0
        public void CalculateModeReturnsNothing()
        {
            var modeCalculator = new ModeCalculator();

            var testData = new List<decimal>();

            modeCalculator.CalculateMode(testData);
        }
Example #3
0
        public void CalculateModeReturnsMostCommon()
        {
            var modeCalculator = new ModeCalculator();

            var testData = new List<decimal>();

            testData.Add(1);
            testData.Add(1);
            testData.Add(2);
            testData.Add(3);
            testData.Add(3);
            testData.Add(3);

            var mode = modeCalculator.CalculateMode(testData);

            Assert.AreEqual("3", mode);
        }
Example #4
0
        public void CalculateModeReturnsMostCommon2()
        {
            var modeCalculator = new ModeCalculator();

            var testData = new List<decimal>();

            testData.Add(199);
            testData.Add(254);
            testData.Add(199);
            testData.Add(233);
            testData.Add(998);
            testData.Add(199);

            var mode = modeCalculator.CalculateMode(testData);

            Assert.AreEqual("199", mode);
        }