public void PostSearchShould_RedirectToGetSearchWithCorrectParameters(string category, string searchBy, string pattern) { var serviceMock = new Mock <ISearchService>(); var controller = new Web.Controllers.SearchController(serviceMock.Object); var viewModel = new SearchViewModel() { Category = category, SearchBy = searchBy, Pattern = pattern }; controller.WithCallTo(c => c.Search(viewModel)) .ShouldRedirectTo((Web.Controllers.SearchController c) => c.Search(viewModel.Category, viewModel.SearchBy, viewModel.Pattern, 10, 1)); }
public void GetSearchShould_ReturnCorrectView(string category, string searchBy, string pattern) { var serviceMock = new Mock <ISearchService>(); InitializeMapper(); var list = new List <Place>() { new Place() { Name = "Pesho's restaurant", Type = "Restaurant" } }; var expectedModel = new List <PlaceShortViewModel>() { new PlaceShortViewModel() { Name = "Pesho's restaurant" } }.ToPagedList(1, 1); serviceMock.Setup(s => s.FindBy(category, searchBy, pattern)) .Returns(list.AsQueryable()); var controller = new Web.Controllers.SearchController(serviceMock.Object); controller .WithCallTo(c => c.Search(category, searchBy, pattern, 1, 1)) .ShouldRenderView("List"); //.WithModel<PagedList.IPagedList<FindAndBook.Web.Models.Places.PlaceShortViewModel>>(m => //{ // CollectionAssert.AreEqual(expectedModel, m); //}); }