Exemplo n.º 1
0
        public void SearchLastNumberTest()
        {
            // Arrange
            int[] sortedArray = Enumerable.Range(-500000, 1000001).ToArray();
            int   number      = 500000;
            InconsistentBinarySearch useless5thBinarySearch = new InconsistentBinarySearch();
            int expectedResult = 1000000;
            // Act (1 Zeile!)
            int result = useless5thBinarySearch.Search(number, sortedArray);

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

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