Ejemplo n.º 1
0
        public async Task AddAsync_ForNullCategoryId_ShouldCreateRootCategory()
        {
            //arrange
            var productCategoryRepository = new Mock <IProductCategoryRepository>();
            var name    = "Name";
            var nameEng = "nameEng";
            var sut     = new ProductCategoryCommandService(productCategoryRepository.Object);

            //act
            await sut.AddAsync(name, nameEng, null, false);

            //assert
            productCategoryRepository.Verify(s => s.AddAsync(It.IsAny <ProductCategory>()), Times.Once);
            productCategoryRepository.Verify(s => s.GetAndEnsureExistAsync(It.IsAny <Guid>()), Times.Never);
        }
Ejemplo n.º 2
0
        public async Task AddAsync_ForSpecificCategoryId_ShouldAddCategoryAsChild()
        {
            //arrange
            var productCategoryRepository = new Mock <IProductCategoryRepository>();
            var name    = "Name";
            var nameEng = "nameEng";

            productCategoryRepository.Setup(s => s.GetAndEnsureExistAsync(It.IsAny <Guid>())).ReturnsAsync(new ProductCategory(name, nameEng, false));
            var sut = new ProductCategoryCommandService(productCategoryRepository.Object);

            //act
            await sut.AddAsync(name, nameEng, Guid.NewGuid(), false);

            //assert
            productCategoryRepository.Verify(s => s.AddAsync(It.IsAny <ProductCategory>()), Times.Never);
            productCategoryRepository.Verify(s => s.GetAndEnsureExistAsync(It.IsAny <Guid>()), Times.Once);
        }