Beispiel #1
0
 public async Task <bool> ExistsCategory(Guid categoryId)
 {
     using (IBlogCategory blogcategorySvc = new BlogCategoryService())
     {
         return(await blogcategorySvc.GetAll().AnyAsync(m => m.Id == categoryId));
     }
 }
Beispiel #2
0
 public async Task <int> GetCategoryDataCount(Guid id)
 {
     using (IBlogCategory blogCategorySvc = new BlogCategoryService())
     {
         Guid allId = Guid.Parse("00000000-0000-0000-0000-000000000001");
         return(await blogCategorySvc.GetAll().CountAsync(m => m.UserId == id || m.Id == allId));
     }
 }
Beispiel #3
0
 public async Task <List <BlogCategoryDto> > GetCategoriesByCount(Guid userId, int count)
 {
     using (IBlogCategory blogCategorySvc = new BlogCategoryService())
     {
         Guid allId = Guid.Parse("00000000-0000-0000-0000-000000000001");
         return(await blogCategorySvc.GetAll().Where(m => m.UserId == userId || m.Id == allId).Select(m => new BlogCategoryDto()
         {
             Id = m.Id,
             BlogCategoryName = m.CategoryName
         }).Take(count).ToListAsync());
     }
 }
Beispiel #4
0
        public void WhenGetAll_ReturnResult()
        {
            var responseMock = new List <BlogCategory>();

            responseMock.Add(new BlogCategory {
                Name = "Category Alpha"
            });
            responseMock.Add(new BlogCategory {
                Name = "Category Beta"
            });
            responseMock.Add(new BlogCategory {
                Name = "Category Gamma"
            });

            var persistenceMock = new Mock <IBlogCategoryRepository>();

            persistenceMock.Setup(p => p.GetAll()).Returns(responseMock);

            var service    = new BlogCategoryService(persistenceMock.Object);
            var categories = service.GetAll();

            Assert.NotNull(categories);
            Assert.Equal(3, categories.ToList().Count);
        }