public void BinarySearch_PassSortedBookArrayAndSoughtValue_SearchByPrice_ReturnIndexOfValue() { // Arange BookForTests[] array = new BookForTests[] { new BookForTests() { Name = "First", Price = 12 }, new BookForTests() { Name = "Second", Price = 19 }, new BookForTests() { Name = "Third", Price = 22 } }; BookForTests soughtValue = new BookForTests() { Name = "OTHER", Price = 12 }; int expectedIndex = 0; // Act int?actualIndex = BinarySearch(array, soughtValue); // Assert Assert.AreEqual(expectedIndex, actualIndex); }
public void MergeSort_TakeBookArray_ReturnSortedArrayByPrice() { BookForTests[] array = new BookForTests[] { new BookForTests() { Name = "Second", Price = 19 }, new BookForTests() { Name = "First", Price = 12 } }; // Arrange BookForTests[] expectedResult = new BookForTests[array.Length]; Array.Copy(array, expectedResult, array.Length); Array.Sort(expectedResult); // Act MergeSort(array); // Assert CollectionAssert.AreEqual(expectedResult, array); }