public void SortByNameTest_ReturnsSortedList() { //Arrange var mock = new Mock <IRepository <Edition> >(); mock.Setup(a => a.List()).Returns(new List <Edition>() { new Edition() { Name = "Edition", Description = "Edition is Edition", DateNextPublication = DateTime.UtcNow, Language = "eng" }, new Edition() { Name = "Edition1", Description = "Edition is Edition1", DateNextPublication = DateTime.UtcNow, Language = "eng" } }); EditionServices service = new EditionServices(mock.Object); //Act var result = service.SortByName(true); //Assert Assert.AreEqual("Edition", result[0].Name); }
public ActionResult SortByName(bool order) { var items = _editionService.SortByName(order); var editions = EditionModel.ToModelList(items); return(View("Index", editions)); }
public void SortByNameTest_ReturnsEmptyList() { //Arrange var mock = new Mock <IRepository <Edition> >(); mock.Setup(a => a.List()).Returns(new List <Edition>()); EditionServices service = new EditionServices(mock.Object); //Act var result = service.SortByName(true); //Assert Assert.AreEqual(0, result.Count); }