public void EditChildCategoryWhithInvaliParentCategoryIdShouldReturnFalse()
        {
            var options = new DbContextOptionsBuilder <XeonDbContext>()
                          .UseInMemoryDatabase(databaseName: "EditChildCategory_ChildCategories_Database")
                          .Options;
            var dbContext = new XeonDbContext(options);

            var parentCategoryName = "Computers";

            dbContext.ParentCategories.Add(new ParentCategory {
                Name = parentCategoryName
            });
            dbContext.SaveChanges();

            var parentCategory = dbContext.ParentCategories.FirstOrDefault(x => x.Name == parentCategoryName);

            var childCategoriesService = new ChildCategoriesService(dbContext);

            var childCategoryName        = "Cables";
            var childCategoryDescription = "USB";
            var childCategory            = childCategoriesService.CreateChildCategory(childCategoryName, childCategoryDescription, parentCategory.Id);

            var newChildCategoryName        = "Monitors";
            var newChildCategoryDescription = "17''";
            var invalidParentCategoryId     = 121;
            var isChildCategoryEdit         = childCategoriesService.EditChildCategory(childCategory.Id, newChildCategoryName, newChildCategoryDescription, invalidParentCategoryId);

            Assert.False(isChildCategoryEdit);
        }
        public void EditChildCategoryShouldReturnTrueAndEditCorrectlyChildCategory()
        {
            var options = new DbContextOptionsBuilder <XeonDbContext>()
                          .UseInMemoryDatabase(databaseName: "EditChildCategory_ChildCategories_Database")
                          .Options;
            var dbContext = new XeonDbContext(options);

            var parentCategoryName = "Computers";

            dbContext.ParentCategories.Add(new ParentCategory {
                Name = parentCategoryName
            });
            dbContext.SaveChanges();

            var parentCategory = dbContext.ParentCategories.FirstOrDefault(x => x.Name == parentCategoryName);

            var childCategoriesService = new ChildCategoriesService(dbContext);

            var childCategoryName        = "Cables";
            var childCategoryDescription = "USB";
            var childCategory            = childCategoriesService.CreateChildCategory(childCategoryName, childCategoryDescription, parentCategory.Id);

            var newChildCategoryName        = "Monitors";
            var newChildCategoryDescription = "17''";
            var isChildCategoryEdit         = childCategoriesService.EditChildCategory(childCategory.Id, newChildCategoryName, newChildCategoryDescription, parentCategory.Id);

            var childCategoryExpectedImageUrl = string.Format(GlobalConstants.CHILD_CATEGORY_PATH_TEMPLATE, childCategory.Id);

            Assert.Equal(newChildCategoryName, childCategory.Name);
            Assert.Equal(newChildCategoryDescription, childCategory.Description);
            Assert.True(isChildCategoryEdit);
        }
        public void EditChildCategoryWhithInvalidChildCategoryIdShouldReturnFalse()
        {
            var options = new DbContextOptionsBuilder <XeonDbContext>()
                          .UseInMemoryDatabase(databaseName: "EditChildCategory_ChildCategories_Database")
                          .Options;
            var dbContext = new XeonDbContext(options);

            var childCategoriesService = new ChildCategoriesService(dbContext);

            var newChildCategoryName        = "Monitors";
            var newChildCategoryDescription = "17''";
            var invalidChildCategoryId      = 121;
            var parentCategoryId            = 131;
            var isChildCategoryEdit         = childCategoriesService.EditChildCategory(invalidChildCategoryId, newChildCategoryName, newChildCategoryDescription, parentCategoryId);

            Assert.False(isChildCategoryEdit);
        }