Пример #1
0
        public void VentaConProductosQueNoEstanEnLaListaDePreciosDelCliente()
        {
            _venta = new Venta.VentaBuilder(_usuarioDuvan, _clienteDuvan).Build();

            VentaDetalle detalle1 = new VentaDetalle.VentaDetalleBuilder(_venta, _bandejaDeMaduro).
                                    SetCantidad(10).SetValor(3600).Build();

            _venta.AgregarDetalle(detalle1);

            Assert.AreEqual(36000, detalle1.ValorTotal);

            VentaDetalle detalle = new VentaDetalle.VentaDetalleBuilder(_venta, _bandejaDeLeche).
                                   SetCantidad(10).SetValor(3900).Build();

            _venta.AgregarDetalle(detalle);

            Assert.AreEqual(39000, detalle.ValorTotal);

            VentaDetalle detalle2 = new VentaDetalle.VentaDetalleBuilder(_venta, _unidadesMedianasDeMaduro).
                                    SetCantidad(10).SetValor(500).Build();

            _venta.AgregarDetalle(detalle2);

            Assert.AreEqual(5000, detalle2.ValorTotal);

            Assert.AreEqual(3, _venta.VentaDetalles.Count);
            Assert.AreEqual(25000, _venta.UtilidadReal);
            Assert.AreEqual(80000, _venta.Total);
        }
Пример #2
0
        public void VentaConProductosSinExistenciasSuficientes()
        {
            _venta = new Venta.VentaBuilder(_usuarioDuvan, _clienteDuvan).Build();

            InvalidOperationException ex = Assert.Throws <InvalidOperationException>(() =>
            {
                VentaDetalle detalle1 = new VentaDetalle.VentaDetalleBuilder(_venta, _bandejaDeMaduro).
                                        SetCantidad(30).SetValor(3600).Build();
                _venta.AgregarDetalle(detalle1);
            });

            Assert.AreEqual($"El producto Bandeja de maduro no " +
                            $"tiene existencias suficientes, solo tiene 25 Unidades", ex.Message);
        }
Пример #3
0
        public void VentaPagarMasDelPendiente()
        {
            _venta = new Venta.VentaBuilder(_usuarioDuvan, _clienteDuvan).Build();
            #region DetallesDeVenta

            VentaDetalle detalle1 = new VentaDetalle.VentaDetalleBuilder(_venta, _bandejaDeMaduro).
                                    SetCantidad(10).SetValor(3600).Build();
            _venta.AgregarDetalle(detalle1);

            VentaDetalle detalle = new VentaDetalle.VentaDetalleBuilder(_venta, _bandejaDeLeche).
                                   SetCantidad(10).SetValor(3900).Build();
            _venta.AgregarDetalle(detalle);

            VentaDetalle detalle2 = new VentaDetalle.VentaDetalleBuilder(_venta, _envueltoDeMaduro).
                                    SetCantidad(10).SetValor(4300).Build();
            _venta.AgregarDetalle(detalle2);
            #endregion

            _venta.SetDescuento(2000);
            Assert.AreEqual(3, _venta.VentaDetalles.Count);
            Assert.AreEqual(118000, _venta.Total);
            Assert.AreEqual(116000, _venta.TotalReal);
            Assert.AreEqual(34000, _venta.UtilidadReal);
            Assert.AreEqual(Estado.Pendiente, _venta.Estado);

            VentaAbono abono = new VentaAbono.VentaAbonoBuilder(_venta, 60000).Build();
            _venta.AgregarAbono(abono);

            Assert.AreEqual(60000, _venta.Pagado);

            InvalidOperationException ex = Assert.Throws <InvalidOperationException>(() =>
            {
                VentaAbono abono1 = new VentaAbono.VentaAbonoBuilder(_venta, 60000).Build();
                _venta.AgregarAbono(abono1);
            });

            Assert.AreEqual($"El valor a abonar es " +
                            $"superior al pendiente de 56000", ex.Message);
            Assert.AreEqual(56000, _venta.Pendiente);
            Assert.AreEqual(Estado.Pendiente, _venta.Estado);
        }
Пример #4
0
        public void VentaConProductosQueNoSonParaVender()
        {
            _venta = new Venta.VentaBuilder(_usuarioDuvan, _clienteDuvan).Build();

            VentaDetalle detalle1 = new VentaDetalle.VentaDetalleBuilder(_venta, _bandejaDeMaduro).
                                    SetCantidad(10).SetValor(3600).Build();

            _venta.AgregarDetalle(detalle1);

            Assert.AreEqual(36000, detalle1.ValorTotal);

            VentaDetalle detalle;
            InvalidOperationException ex = Assert.Throws <InvalidOperationException>(() =>
            {
                detalle = new VentaDetalle.VentaDetalleBuilder(_venta, _leche).
                          SetCantidad(10).SetValor(3900).Build();
                _venta.AgregarDetalle(detalle);
            });

            Assert.AreEqual($"El producto Leche " +
                            $"no se puede vender, es solo para MateriaPrima", ex.Message);
        }
Пример #5
0
        public void VentaRealizadaConExito()
        {
            _venta = new Venta.VentaBuilder(_usuarioDuvan, _clienteDuvan).Build();

            VentaDetalle detalle1 = new VentaDetalle.VentaDetalleBuilder(_venta, _bandejaDeMaduro).
                                    SetCantidad(10).SetValor(3600).Build();

            _venta.AgregarDetalle(detalle1);

            VentaDetalle detalle = new VentaDetalle.VentaDetalleBuilder(_venta, _bandejaDeLeche).
                                   SetCantidad(10).SetValor(3900).Build();

            _venta.AgregarDetalle(detalle);

            VentaDetalle detalle2 = new VentaDetalle.VentaDetalleBuilder(_venta, _envueltoDeMaduro).
                                    SetCantidad(10).SetValor(4300).Build();

            _venta.AgregarDetalle(detalle2);

            _venta.SetDescuento(2000);
            Assert.AreEqual(3, _venta.VentaDetalles.Count);
            Assert.AreEqual(34000, _venta.UtilidadReal);
        }
Пример #6
0
        public void VentaPagarPendiente()
        {
            _venta = new Venta.VentaBuilder(_usuarioDuvan, _clienteDuvan).Build();
            #region DetallesDeVenta

            VentaDetalle detalle1 = new VentaDetalle.VentaDetalleBuilder(_venta, _bandejaDeMaduro).
                                    SetCantidad(10).SetValor(3600).Build();
            _venta.AgregarDetalle(detalle1);

            VentaDetalle detalle = new VentaDetalle.VentaDetalleBuilder(_venta, _bandejaDeLeche).
                                   SetCantidad(10).SetValor(3900).Build();
            _venta.AgregarDetalle(detalle);

            VentaDetalle detalle2 = new VentaDetalle.VentaDetalleBuilder(_venta, _envueltoDeMaduro).
                                    SetCantidad(10).SetValor(4300).Build();
            _venta.AgregarDetalle(detalle2);
            #endregion

            _venta.SetDescuento(2000);
            Assert.AreEqual(3, _venta.VentaDetalles.Count);
            Assert.AreEqual(118000, _venta.Total);
            Assert.AreEqual(116000, _venta.TotalReal);
            Assert.AreEqual(34000, _venta.UtilidadReal);
            Assert.AreEqual(Estado.Pendiente, _venta.Estado);

            VentaAbono abono = new VentaAbono.VentaAbonoBuilder(_venta, 60000).Build();
            _venta.AgregarAbono(abono);

            Assert.AreEqual(60000, _venta.Pagado);

            VentaAbono abono1 = new VentaAbono.VentaAbonoBuilder(_venta, 56000).Build();
            _venta.AgregarAbono(abono1);

            Assert.AreEqual(0, _venta.Pendiente);
            Assert.AreEqual(116000, _venta.Pagado);
            Assert.AreEqual(Estado.Pagado, _venta.Estado);
        }