Exemple #1
0
        public void should_return_lowest_index_above_value_for_first_and_intermidiate_elements()
        {
            SortedDictionary <double, double> collection = new SortedDictionary <double, double>
            {
                { 0.25, 1 },
                { 0.5, 3 },
                { 0.75, 4 },
                { 1, 9 },
                { 1.25, 10 },
                { 1.5, 16 },
                { 2, 18 },
                { 3, 21 },
                { 4, 34 },
                { 5, 18 },
                { 6, 21 },
                { 7, 34 },
                { 8, 18 },
                { 9, 21 },
                { 10, 34 }
            };

            double val1 = 0.26;
            double val2 = 0.37;
            double val3 = 2.12;
            double val4 = 9.25;

            double ind1 = Tools.FindLowestIndexAbove(collection, val1);
            double ind2 = Tools.FindLowestIndexAbove(collection, val2);
            double ind3 = Tools.FindLowestIndexAbove(collection, val3);
            double ind4 = Tools.FindLowestIndexAbove(collection, val4);

            Assert.IsTrue(ind1.Equals(1) && ind2.Equals(1) && ind3.Equals(7) && ind4.Equals(14));
        }