Пример #1
0
        public void TestMedianEvenCount()
        {
            var m = new Median();

            m.Init();
            m.Accumulate(new Pair {
                Value = 1, Name = "1"
            });
            m.Accumulate(new Pair {
                Value = 1, Name = "1"
            });
            m.Accumulate(new Pair {
                Value = 5, Name = "5"
            });
            m.Accumulate(new Pair {
                Value = 7, Name = "7"
            });
            m.Accumulate(new Pair {
                Value = 8, Name = "8"
            });
            m.Accumulate(new Pair {
                Value = 1000, Name = "1000"
            });
            m.Accumulate(new Pair {
                Value = 10000, Name = "10000"
            });
            Assert.AreEqual("7", m.Terminate().Value);
        }
Пример #2
0
        public void TestMedianOddCount()
        {
            var m = new Median();

            m.Init();
            m.Accumulate(new Pair {
                Value = 1, Name = "1"
            });
            m.Accumulate(new Pair {
                Value = 1, Name = "1"
            });
            m.Accumulate(new Pair {
                Value = 5, Name = "5"
            });
            m.Accumulate(new Pair {
                Value = 6, Name = "6"
            });
            m.Accumulate(new Pair {
                Value = 1000, Name = "1000"
            });
            m.Accumulate(new Pair {
                Value = 10000, Name = "10000"
            });
            Assert.AreEqual("5 - 6", m.Terminate().Value); // Excel gives 5.5 here
        }
Пример #3
0
 public void TestMedianEvenCount()
 {
     var m = new Median();
     m.Init();
     m.Accumulate(new Pair { Value = 1, Name = "1" });
     m.Accumulate(new Pair { Value = 1, Name = "1" });
     m.Accumulate(new Pair { Value = 5, Name = "5" });
     m.Accumulate(new Pair { Value = 7, Name = "7" });
     m.Accumulate(new Pair { Value = 8, Name = "8" });
     m.Accumulate(new Pair { Value = 1000, Name = "1000" });
     m.Accumulate(new Pair { Value = 10000, Name = "10000" });
     Assert.AreEqual("7", m.Terminate().Value);
 }
Пример #4
0
 public void TestMedianOddCount()
 {
     var m = new Median();
     m.Init();
     m.Accumulate(new Pair { Value = 1, Name = "1" });
     m.Accumulate(new Pair { Value = 1, Name = "1" });
     m.Accumulate(new Pair { Value = 5, Name = "5" });
     m.Accumulate(new Pair { Value = 6, Name = "6" });
     m.Accumulate(new Pair { Value = 1000, Name = "1000" });
     m.Accumulate(new Pair { Value = 10000, Name = "10000" });
     Assert.AreEqual("5 - 6", m.Terminate().Value); // Excel gives 5.5 here
 }