public void GetAllPostsByCategory_Expects_True() { List <Post> posts = null; posts = _postLogic.GetAllPostsByCategory(1); Assert.AreEqual(2, posts.Count()); }
public IActionResult Index(int category_id) { CategoryPageViewModel model = new CategoryPageViewModel() { Categories = _categoryLogic.GetAll().Select(c => new CategoryViewModel { Id = c.CategoryId, Name = c.Name }).ToList(), Posts = _postLogic.GetAllPostsByCategory(category_id).Select(c => new PostViewModel { Title = c.Title, Content = c.Content, PostId = c.PostId, AuraAmount = c.Aura.Amount, PostDate = c.PostDate, UserName = c.User.Name, CategoryName = c.Category.Name }).ToList(), CategoryName = _categoryLogic.GetCategoryById(category_id).Name, }; return(View(model)); }