Exemple #1
0
        public async Task should_update_product_line()
        {
            var ProductCategoryId = Guid.NewGuid();
            var ProductLineId     = Guid.NewGuid();
            var model             = new ProductLineRequestModel
            {
                Name = "Nokia 210",
                ProductCategoryId = ProductCategoryId
            };

            var productLineToUpdate = new ProductLineBuilder()
                                      .WithName("nokia A")
                                      .WithProductCategoryId(ProductCategoryId)
                                      .Construct();


            _productLineRepository.ValidateEntityExistence(ProductCategoryId).Returns(true);
            _productLineRepository.GetById(ProductLineId).Returns(productLineToUpdate);

            await _productLineService.Update(ProductLineId, model);

            await _productLineRepository
            .Received(1)
            .Update(Arg.Is <ProductLine>(x => x.ProductCategoryId == ProductCategoryId &&
                                         x.Name.ToString() == model.Name));
        }
        public async Task <IActionResult> Update([FromRoute] Guid id, [FromBody] ProductLineRequestModel request)
        {
            await _productLineService.Update(id, request);

            return(Accepted());
        }