コード例 #1
0
        public void SearchLastNumberTest()
        {
            // Arrange
            int[] sortedArray = Enumerable.Range(-500000, 1000001).ToArray();
            int   number      = 500000;
            IterativeDynamicBinarySearch iterativeDynamicBinarySearch = new IterativeDynamicBinarySearch();
            int expectedResult = 1000000;
            // Act (1 Zeile!)
            int result = iterativeDynamicBinarySearch.Search(number, sortedArray);

            // Assert rückgabe vom Act soll überprüft werden
            Assert.AreEqual(expectedResult, result);
        }
コード例 #2
0
        public void SearchRandomNumberTest2()
        {
            // Arrange
            int[]  sortedArray = Enumerable.Range(-500000, 1000001).ToArray();
            Random rnd         = new Random();
            int    number      = rnd.Next(-499999, 1000000);
            IterativeDynamicBinarySearch iterativeDynamicBinarySearch = new IterativeDynamicBinarySearch();
            List <int> list           = sortedArray.ToList();
            int        expectedResult = list.IndexOf(number);
            // Act (1 Zeile!)
            int result = iterativeDynamicBinarySearch.Search(number, sortedArray);

            // Assert rückgabe vom Act soll überprüft werden
            Assert.AreEqual(expectedResult, result);
        }