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 ValidateEntityExistence(Guid entityId) { var productLineExists = await _productLineRepository.ValidateEntityExistence(entityId); if (!productLineExists) { _notificationService.AddNotification("ValidateEntityError", "Esta linha de produto não existe"); } }