public void SortByName() { // Arrange var originalList = db.Get(); var sortedList = originalList.OrderByDescending(r => r.LastName).ToList(); // Act var testList = controller.SortByName().ToList(); var passTest = true; for (int i = 0; i < testList.Count() - 1 && passTest; i++) { passTest &= (testList[i].LastName.CompareTo(testList[i + 1].LastName)) >= 0; } // Assert Assert.IsTrue(passTest); }