private Category GetCategory(string modelCategory) { var category = this.data.Categories.All() .FirstOrDefault(c => c.Name == modelCategory); if (category == null) { category = new Category { Name = modelCategory }; this.data.Categories.Add(category); } return category; }
private Article[] GenerateValidTestArticles(int count) { Article[] articles = new Article[count]; var category = new Category() { ID = 1, Name = "Test Category" }; var tags = new Tag[]{ new Tag(){ ID = 1, Name="tag" } }; for (int i = 0; i < count; i++) { var article = new Article { ID = i, Title = " Title #" + i, Content = "The Content #" + i, Category = category, DateCreated = DateTime.Now, Tags = tags, Author = new ApplicationUser() }; articles[i] = article; } return articles; }