AgregarLinea() public method

public AgregarLinea ( Producto producto ) : void
producto Producto
return void
        public void IncrementaLaCantidadAlAgregarUnaLineaCuandoElProductoExiste()
        {
            var carroCompras = new CarroCompras();
            carroCompras.AgregarLinea(new Producto { Id = 1 });

            carroCompras.AgregarLinea(new Producto { Id = 1 });

            Assert.AreEqual(2, carroCompras.CantidadProductos);
        }
        public void AgregarLinea_ProductoYaExiste_IncrementaLaCantidadDeLaLinea()
        {
            var carroCompras = new CarroCompras();
            carroCompras.AgregarLinea(new Producto { Id = 1 });

            carroCompras.AgregarLinea(new Producto { Id = 1 });

            Assert.AreEqual(2, carroCompras.CantidadProductos);
        }
        public ActionResult Agregar(CarroCompras carroCompras, int id, string regresarUrl)
        {
            Producto producto = context.Productos.FirstOrDefault(p => p.Id == id);
            carroCompras.AgregarLinea(producto);

            return RedirectToAction("Mostrar", new { regresarUrl });
        }
        public void AgregaUnaNuevaLineaCuandoElProductoNoExiste()
        {
            var carroCompras = new CarroCompras();

            carroCompras.AgregarLinea(new Producto());

            Assert.AreEqual(1, carroCompras.CantidadProductos);
        }
        public void ActualizaLaCantidadCuandoElProductoExiste()
        {
            var carroCompras = new CarroCompras();
            carroCompras.AgregarLinea(new Producto { Id = 1 });

            carroCompras.ActualizarLinea(1, 3);

            Assert.AreEqual(3, carroCompras.CantidadProductos);
        }
        public void ActualizarLinea_ProductoExiste_CantidadIncrementada()
        {
            var carroCompras = new CarroCompras();
            carroCompras.AgregarLinea(new Producto { Id = 1 });

            carroCompras.ActualizarLinea(1, 3);

            Assert.AreEqual(3, carroCompras.CantidadProductos);
        }
        public void ActualizarLinea_CantidadCero_RemueveLaLinea()
        {
            var carroCompras = new CarroCompras();
            carroCompras.AgregarLinea(new Producto { Id = 1 });

            carroCompras.ActualizarLinea(1, 0);

            Assert.AreEqual(0, carroCompras.CantidadProductos);
        }
        public void AgregarLinea_ProductoNoExiste_LineaAgregada()
        {
            //Arrange
            var carroCompras = new CarroCompras();

            //Act
            carroCompras.AgregarLinea(new Producto());

            //Assert
            Assert.AreEqual(1, carroCompras.CantidadProductos);
        }
        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);
        }
        public void DataDrivenTesting()
        {
            var carroCompras = new CarroCompras();
            int cantidad = int.Parse(this.TestContext.DataRow["Cantidad"].ToString());
            int precio = int.Parse(this.TestContext.DataRow["Precio"].ToString()); ;
            int costoenvio = int.Parse(this.TestContext.DataRow["CostoEnvio"].ToString());
            for (int i = 0; i < cantidad; i++)
            {
                carroCompras.AgregarLinea(new Producto
                {
                    Id = 1,
                    Precio = precio
                });
            }
            carroCompras.CostoEnvio = costoenvio;

            var total = carroCompras.Total;

            Assert.AreEqual(int.Parse(this.TestContext.DataRow["Total"].ToString()),total);
        }
        public void RemueveLaLineaAlActualizarCuandoLaCantidadEsCero()
        {
            var carroCompras = new CarroCompras();
            carroCompras.AgregarLinea(new Producto { Id = 1 });

            carroCompras.ActualizarLinea(1, 0);

            Assert.AreEqual(0, carroCompras.CantidadProductos);
        }