Example #1
0
        public void TestFindNumber()
        {
            int[] nonSortedArray = DummyData <int> .CreateArray(100000, new int[] { 1, 2, 3, 4, 5, 6, 7 });

            int[] sortedArray = new int[100000];

            for (int i = 0; i < sortedArray.Length; i++)
            {
                sortedArray[i] = i + 1;
            }

            //Stopwatch watch = Stopwatch.StartNew();
            //
            //bool sorted = SearchAlgorithms.NumericlySorted(sortedArray);
            //
            //watch.Stop();

            Stopwatch watch = Stopwatch.StartNew();

            int index = SearchAlgorithms.FindNumber(sortedArray, 139);

            watch.Stop();

            //Assert.Equal(0, watch.ElapsedTicks);
            //
            //Assert.True(sorted);

            //Assert.Equal(0, watch.ElapsedTicks);

            Assert.True(sortedArray[index] == 139);
        }