public async void IndexByCategory_ReturnNotFound(int categoryID, string order) { var controller = new ServicesController(Context, UserManager); controller.ControllerContext.HttpContext = new DefaultHttpContext { User = ClientLog }; var result = await controller.IndexByCategory(categoryID, order, 1); var viewResult = Assert.IsType <ViewResult>(result); Assert.Equal("/Views/Shared/NotFound.cshtml", viewResult.ViewName); }
public async void IndexByCategory_ReturnViewResult(int categoryID, string order) { var controller = new ServicesController(Context, UserManager); controller.ControllerContext.HttpContext = new DefaultHttpContext { User = ClientLog }; var result = await controller.IndexByCategory(categoryID, order, 1); var viewResult = Assert.IsType <ViewResult>(result); var model = Assert.IsAssignableFrom <IEnumerable <Service> >(viewResult.ViewData.Model); Assert.NotNull(model); Assert.Equal(Context.Service.Where(cat => cat.ServiceCategoryID == categoryID).Count(), model.Count()); }