TiendaVirtual.Domain.CarroCompras.RemoverLinea C# (CSharp) Method

RemoverLinea() public method

public RemoverLinea ( int productoId ) : void
productoId int
return void
        public void RemoverLinea(int productoId)
        {
            LineaCarroCompras linea = BuscarLinea(productoId);
            if (linea == null)
                throw new Exception("No existe el producto");

            this.detalle.RemoveAll(l => l.Producto.Id == productoId);
        }

Usage Example

        public void RemoverLinea_ProductoExiste_RemueveLaLinea()
        {
            //Arrange
            var carroCompras = new CarroCompras();
            carroCompras.AgregarLinea(new Producto { Id = 1 });

            //Act
            carroCompras.RemoverLinea(1);

            //Assert
            Assert.AreEqual(0, carroCompras.CantidadProductos);
        }
All Usage Examples Of TiendaVirtual.Domain.CarroCompras::RemoverLinea