Ejemplo n.º 1
0
        public void ConvertToEntity_InputNotNull_ReturnSameName()
        {
            CreateProductCategoryInput input = MockCreateProductCategoryInput();

            ProductCategory category = input.ConvertToEntity();

            Assert.Equal(input.Name, category.Name);
        }
Ejemplo n.º 2
0
        public void ConvertToEntity_InputNotNull_ReturnSameSubCategories()
        {
            CreateProductCategoryInput input = MockCreateProductCategoryInput();

            ProductCategory category = input.ConvertToEntity();

            Assert.Equal(input.SubCategories, category.SubCategories);
        }
Ejemplo n.º 3
0
        public void ConvertToEntity_InputNotNull_ReturnEmplyId()
        {
            CreateProductCategoryInput input = MockCreateProductCategoryInput();

            ProductCategory category = input.ConvertToEntity();

            Assert.Equal(Guid.Empty, category.Id);
        }
Ejemplo n.º 4
0
        public async Task <OperationResult <ProductCategoryDto> > CreateAsync(CreateProductCategoryInput input)
        {
            var validationResult = await _productCategoryValidator.ValidateCreateProductCategory(input);

            if (validationResult.IsSuccess)
            {
                var entity = input.ConvertToEntity();

                entity = await _productCategoryRepository.CreateAsync(entity);

                return(OperationResult <ProductCategoryDto> .Success(entity.ConvertToDto(0)));
            }

            return(OperationResult <ProductCategoryDto> .Fail(validationResult));
        }