public void SearchByName_K_Returns_ListOfZeroElements() { //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", Price = 3 }, new Edition() { Name = "Edition1", Description = "Edition is Edition1", DateNextPublication = DateTime.UtcNow, Language = "eng", Price = 5 } }); EditionServices service = new EditionServices(mock.Object); //Act var result = service.SearchByName("k"); //Assert Assert.AreEqual(0, result.Count); }
public ActionResult Search(string search) { var result = _editionService.SearchByName(search); List <EditionModel> editions = EditionModel.ToModelList(result); //db.Books.Where(a => a.Author.Contains(name)).ToList(); ViewBag.searchString = search; if (editions.Count <= 0) { //return HttpNotFound(); } return(PartialView("_EditionSearch", editions)); }