public void DeleteByIdTest() { var repository = CategoryRepository.Create(); var category = this.CreateArticle(repository, SeedCategory.Create()); var service = this.GetArticlesService(repository); var result = service.DeleteById(category.Id); Assert.True(category.IsDeleted); }
public void GetAllCategoriesSingleResultTest() { var repository = CategoryRepository.Create(); var category = this.CreateArticle(repository, SeedCategory.Create()); var service = this.GetArticlesService(repository); var result = service.GetAllCategories <CategoryDumyModel>(); Assert.Single(result); }
public void HardDeleteByIdTest() { var repository = CategoryRepository.Create(); var category = this.CreateArticle(repository, SeedCategory.Create()); var service = this.GetArticlesService(repository); service.HardDeleteById(category.Id).GetAwaiter(); Assert.Equal(0, repository.AllWithDeleted().Count()); }
public void GetAllCategoriesWithAnySubCategoriesTest() { var repository = CategoryRepository.Create(); var category = this.CreateArticle(repository, SeedCategory.Create()); var secondCategory = this.CreateArticle(repository, SeedCategory.CreateSecond()); var thirdCategory = this.CreateArticle(repository, SeedCategory.CreateThird()); var service = this.GetArticlesService(repository); var result = service.GetAllCategoriesWithAnySubCategories <CategoryDumyModel>(); Assert.Single(result); }
public void GetCountOfDeletedCategories() { var repository = CategoryRepository.Create(); var category = this.CreateArticle(repository, SeedCategory.Create()); var secondCategory = this.CreateArticle(repository, SeedCategory.CreateSecond()); var thirdCategory = this.CreateArticle(repository, SeedCategory.CreateThird()); var service = this.GetArticlesService(repository); var result = service.GetCountOfDeletedCategories(); Assert.Equal(1, result); }
public void GetCategoryByIdTest() { var repository = CategoryRepository.Create(); var category = this.CreateArticle(repository, SeedCategory.Create()); var secondCategory = this.CreateArticle(repository, SeedCategory.CreateSecond()); var thirdCategory = this.CreateArticle(repository, SeedCategory.CreateThird()); var service = this.GetArticlesService(repository); var result = service.GetCategoryById <CategoryDumyModel>(1).GetAwaiter().GetResult(); Assert.Equal(category.Id, result.Id); }
public void GetCategoryByIdFakeTest() { var repository = CategoryRepository.Create(); var category = this.CreateArticle(repository, SeedCategory.Create()); var secondCategory = this.CreateArticle(repository, SeedCategory.CreateSecond()); var thirdCategory = this.CreateArticle(repository, SeedCategory.CreateThird()); var service = this.GetArticlesService(repository); var result = service.GetCategoryById <CategoryDumyModel>(int.MaxValue).GetAwaiter().GetResult(); Assert.Null(result); }
public void GetCategoryModelByFakeIdTest() { var repository = CategoryRepository.Create(); var category = this.CreateArticle(repository, SeedCategory.Create()); var secondCategory = this.CreateArticle(repository, SeedCategory.CreateSecond()); var thirdCategory = this.CreateArticle(repository, SeedCategory.CreateThird()); var service = this.GetArticlesService(repository); var result = service.GetCategoryModelById(55).GetAwaiter().GetResult(); Assert.Null(result); }
public void CategoryExistsByNameTrueTest() { var repository = CategoryRepository.Create(); var category = this.CreateArticle(repository, SeedCategory.Create()); var secondCategory = this.CreateArticle(repository, SeedCategory.CreateSecond()); var thirdCategory = this.CreateArticle(repository, SeedCategory.CreateThird()); var service = this.GetArticlesService(repository); var result = service.CategoryExistsByName(category.Title).GetAwaiter().GetResult(); Assert.True(result); }
public void CategoryExistsByNameFalseTest() { var name = "someName"; var repository = CategoryRepository.Create(); var category = this.CreateArticle(repository, SeedCategory.Create()); var secondCategory = this.CreateArticle(repository, SeedCategory.CreateSecond()); var thirdCategory = this.CreateArticle(repository, SeedCategory.CreateThird()); var service = this.GetArticlesService(repository); var result = service.CategoryExistsByName(name).GetAwaiter().GetResult(); Assert.False(result); }
public void CreateCategoryAsyncTest() { var repository = CategoryRepository.Create(); var category = this.CreateArticle(repository, SeedCategory.Create()); var service = this.GetArticlesService(repository); service.CreateCategoryAsync(new CategoryCreateInputModel { Title = "New category" }).GetAwaiter(); Assert.Equal(2, repository.All().Count()); }
public void UpdateCategoryTest() { string newName = "New name"; var repository = CategoryRepository.Create(); var category = this.CreateArticle(repository, SeedCategory.Create()); var service = this.GetArticlesService(repository); category.Title = newName; var result = service.UpdateCategory(category); Assert.Equal(newName, category.Title); }
public void GetCategoryByNameOneResultTest() { string categoryName = "One"; var repository = CategoryRepository.Create(); var category = this.CreateArticle(repository, SeedCategory.Create()); var secondCategory = this.CreateArticle(repository, SeedCategory.CreateSecond()); var thirdCategory = this.CreateArticle(repository, SeedCategory.CreateThird()); var service = this.GetArticlesService(repository); var result = service.GetCategoryByName <CategoryDumyModel>(categoryName).GetAwaiter().GetResult(); Assert.Equal(category.Title, result.Title); }
public static void Main(string[] args) { var host = CreateWebHostBuilder(args).Build(); using (var scope = host.Services.CreateScope()) { var services = scope.ServiceProvider; try { var context = services.GetRequiredService <BrokenAPIContext>(); context.Database.Migrate(); SeedCategory.Initialize(services); SeedError.Initialize(services); } catch { } } host.Run(); }
public int Save(SeedCategory seedCategory) { _context.SeedCategories.Add(seedCategory); return(_context.SaveChanges()); }