public ChildCategoriesController(IChildCategoriesService childCategoryService, IParentCategoriesService parentCategoryService, IImagesService imageService, IMapper mapper) { this.childCategoryService = childCategoryService; this.parentCategoryService = parentCategoryService; this.imageService = imageService; this.mapper = mapper; }
public void GetAllParentCategories_WithZeroData_ShouldReturnEmptyResults() { var context = UniShopDbContextInMemoryFactory.InitializeContext(); this.parentCategoriesService = new ParentCategoriesService(context); List <ParentCategoryServiceModel> actualResults = this.parentCategoriesService.GetAllParentCategories().ToList(); int expectedResults = 0; Assert.Equal(expectedResults, actualResults.Count()); }
public HomeController(IChildCategoriesService childCategoryService, IParentCategoriesService parentCategoryService, IProductsService productService, IUserRequestsService userRequestService, IMapper mapper) { this.childCategoryService = childCategoryService; this.parentCategoryService = parentCategoryService; this.productService = productService; this.userRequestService = userRequestService; this.mapper = mapper; }
public void IsHaveParentCategory__WithNonExistentId_ShouldReturnFalse() { string errorMessagePrefix = "ParentCategoriesService IsHaveParentCategory() method does not work properly."; var context = UniShopDbContextInMemoryFactory.InitializeContext(); this.SeedData(context); this.parentCategoriesService = new ParentCategoriesService(context); int nonExistentId = context.ParentCategories.Last().Id + 1; bool actualResults = this.parentCategoriesService.IsHaveParentCategory(nonExistentId); Assert.False(actualResults, errorMessagePrefix); }
public void GetParentCategoryById_WithNonExistentId_ShouldReturnNull() { string errorMessagePrefix = "ParentCategoriesService GetParentCategoryById() method does not work properly."; var context = UniShopDbContextInMemoryFactory.InitializeContext(); this.SeedData(context); this.parentCategoriesService = new ParentCategoriesService(context); int nonExistentId = 5; ParentCategoryServiceModel actualResults = this.parentCategoriesService.GetParentCategoryById(nonExistentId); Assert.True(actualResults == null, errorMessagePrefix); }
public void Delete_WithExistentIdAndWithoutChildCategories_ShouldPassSuccessfully() { string errorMessagePrefix = "ParentCategoriesService Delete() method does not work properly."; var context = UniShopDbContextInMemoryFactory.InitializeContext(); this.SeedData(context); this.parentCategoriesService = new ParentCategoriesService(context); int testId = context.ParentCategories.Last().Id; int expectedCount = context.ParentCategories.Count() - 1; bool actualResult = this.parentCategoriesService.Delete(testId); int actualCount = context.ParentCategories.Count(); Assert.True(actualResult, errorMessagePrefix); Assert.Equal(expectedCount, actualCount); }
public void GetParenyCategoriesById_WithExistentId_ShouldReturnCorrectResults() { string errorMessagePrefix = "ParentCategoriesService GetParentCategoryById() method does not work properly."; var context = UniShopDbContextInMemoryFactory.InitializeContext(); this.SeedData(context); this.parentCategoriesService = new ParentCategoriesService(context); ParentCategoryServiceModel expectedResults = context.ParentCategories.First().To <ParentCategoryServiceModel>(); ParentCategoryServiceModel actualResults = this.parentCategoriesService.GetParentCategoryById(expectedResults.Id); Assert.True(expectedResults.Id == actualResults.Id, errorMessagePrefix + " " + "Id is not returned properly."); Assert.True(expectedResults.Name == actualResults.Name, errorMessagePrefix + " " + "Name is not returned properly."); Assert.True(expectedResults.ChildCategories.Count() == actualResults.ChildCategories.Count(), errorMessagePrefix + " " + "ChildCategories Count is not returned properly."); }
public void Edit_WithNonExistentId_ShouldReturnFalse() { string errorMessagePrefix = "ParentCategoriesService Edit() method does not work properly."; var context = UniShopDbContextInMemoryFactory.InitializeContext(); this.SeedData(context); this.parentCategoriesService = new ParentCategoriesService(context); ParentCategoryServiceModel parentCategoryFromDb = context.ParentCategories.First().To <ParentCategoryServiceModel>(); ParentCategoryServiceModel NonExistrentId = parentCategoryFromDb; NonExistrentId.Id = 10; bool actualResult = this.parentCategoriesService.Edit(NonExistrentId); Assert.False(actualResult, errorMessagePrefix); }
public void Create_WithCorrectData_ShouldSuccessfullyCreate() { string errorMessagePrefix = "ParentCategoriesService Create() method does not work properly."; var context = UniShopDbContextInMemoryFactory.InitializeContext(); this.SeedData(context); this.parentCategoriesService = new ParentCategoriesService(context); ParentCategoryServiceModel testParentCategory = new ParentCategoryServiceModel { Name = "Книги" }; int expectedCount = context.ParentCategories.Count() + 1; bool actualResult = this.parentCategoriesService.Create(testParentCategory); int actualCount = context.ParentCategories.Count(); Assert.True(actualResult, errorMessagePrefix); Assert.Equal(expectedCount, actualCount); }
public void Edit_WithCorrectData_ShouldPassSuccessfully() { string errorMessagePrefix = "ParentCategoriesService Edit() method does not work properly."; var context = UniShopDbContextInMemoryFactory.InitializeContext(); this.SeedData(context); this.parentCategoriesService = new ParentCategoriesService(context); ParentCategoryServiceModel parentCategoryFromDb = context.ParentCategories.First().To <ParentCategoryServiceModel>(); ParentCategoryServiceModel expectedParentCategory = parentCategoryFromDb; expectedParentCategory.Name = "Edit"; bool actualResult = this.parentCategoriesService.Edit(expectedParentCategory); ParentCategoryServiceModel actualParentCategory = context.ParentCategories.FirstOrDefault(p => p.Id == parentCategoryFromDb.Id).To <ParentCategoryServiceModel>(); Assert.True(actualParentCategory.Name == expectedParentCategory.Name, errorMessagePrefix + " " + "Name not editted properly."); Assert.True(actualResult, errorMessagePrefix); }
public ParentCategoriesController(IParentCategoriesService parentCategoriesService) { this.parentCategoriesService = parentCategoriesService; }
public ParentCategoriesController(IParentCategoriesService parentCategoryService, IMapper mapper) { this.parentCategoryService = parentCategoryService; this.mapper = mapper; }
public ChildCategoriesController(IChildCategoriesService childCategoriesService, IParentCategoriesService parentCategoriesService) { this.childCategoriesService = childCategoriesService; this.parentCategoriesService = parentCategoriesService; }
public NavbarComponent(IParentCategoriesService parentCategoriesService) { this.parentCategoriesService = parentCategoriesService; }
public ChildCategoriesService(UniShopDbContext context, IParentCategoriesService parentCategoriesService) { this.context = context; this.parentCategoriesService = parentCategoriesService; }