public void TestDisplayAllRestaurantsDesc() { // Act Restaurant test1 = new Restaurant("Arbys", "2010 Somwhere", 4.4m); Restaurant test2 = new Restaurant("Taco Bell", "2010 Somwhere", 2.4m); Restaurant test3 = new Restaurant("Burger King", "2010 Somwhere", 3.1m); Restaurant test4 = new Restaurant("McDonalds", "2010 Somwhere", 5.0m); Restaurant test5 = new Restaurant("Fazolis", "2010 Somwhere", 1.4m); Restaurant test6 = new Restaurant("Steak n Shake", "2010 Somwhere", 3.2m); Restaurant test7 = new Restaurant("Subway", "2010 Somwhere", 4.8m); Restaurant test8 = new Restaurant("In and Out Burger", "2010 Somwhere", 4.1m); Restaurant test9 = new Restaurant("KFC", "2010 Somwhere", 0.4m); Restaurant test10 = new Restaurant("Sonic", "2010 Somwhere", 1.1m); List <Restaurant> lsExpectList = new List <Restaurant> { test2, test7, test6, test10, test4, test9, test8, test5, test3, test1 }; // Arrange List <Restaurant> lsTestList = new List <Restaurant> { test1, test2, test3, test4, test5, test6, test7, test8, test9, test10 }; List <Restaurant> lsActualList = RestaurantSort.DisplayAllRestaurantDesc(lsTestList); // Assert CollectionAssert.AreEqual(lsExpectList, lsActualList); }
public ActionResult Sort(string sort) { var bl = new Dubuche.BL.RestaurantCRUD(); var list = Dubuche.BL.RestaurantCRUD.Casting(bl.GetAllRestaurants()); var sortedList = list; //var sortedList = RestaurantSort.AlphaSorting(Dubuche.BL.RestaurantCRUD.Casting(list)); //var downSortedList = RestaurantSort.BetaSorting(Dubuche.BL.RestaurantCRUD.Casting(list)); //var ratedSortedList = RestaurantSort.AvgRatingSort(Dubuche.BL.RestaurantCRUD.Casting(list)); //var topThreeSorted = RestaurantSort.AvgRatingSort(Dubuche.BL.RestaurantCRUD.Casting(list)); try { if (sort == "byName") { sortedList = RestaurantSort.AlphaSorting(list); } else if (sort == "byRating") { sortedList = RestaurantSort.AvgRatingSort(list); } else if (sort == "topThree") { sortedList = RestaurantSort.AvgRatingSort(list.Take(3).ToList()); } return(View(sortedList)); } catch { log = LogManager.GetLogger("mistakes"); return(RedirectToAction("Index")); } }
public void BetaSortingTest() { List <Restaurants> restsTests = new List <Restaurants>(); //arrange Restaurants rests = new Restaurants("def"); //arrange restsTests.Add(rests); //arrange List <Restaurants> expected = new List <Restaurants>(); //arrange Restaurants rests2 = new Restaurants("abc"); //arrange restsTests.Add(rests2); //arrange Restaurants rests3 = new Restaurants("def"); //arrange expected.Add(rests3); //arrange Restaurants rests4 = new Restaurants("abc"); //arrange expected.Add(rests4); //arrange List <Restaurants> actual = RestaurantSort.BetaSorting(restsTests); //act Assert.AreEqual(expected[0].Name, actual[0].Name); //assert Assert.AreEqual(expected[1].Name, actual[1].Name); //assert }