Exemple #1
0
        public async Task CrearLineaMenu_FailedCreatingReservaServicio()
        {
            // Arrange
            using (context)
            {
                var  controller = new LineaFacturasController(context);
                Menu menu       = new Menu
                {
                    idServicio = 1,
                    horaInicio = new DateTime(2001, 12, 13, 13, 00, 00),
                    horaFin    = new DateTime(2001, 12, 13, 16, 00, 00)
                };
                int     cantidad = 1;
                Factura factura  = new Factura {
                    idFactura = 1
                };
                Habitacion habitacion = new Habitacion {
                    numero = 101
                };
                bool exResult = false;
                SystemTime.Now = () => new DateTime(2016, 10, 13, 12, 00, 00);
                // Act
                bool result = await controller.CrearLineaMenu(menu, cantidad, factura, habitacion);

                //Assert
                Assert.IsType <bool>(result);
                Assert.Equal(exResult, result);
            }
        }
Exemple #2
0
        public async Task CrearLineaMenu_FacturaIsNull()
        {
            // Arrange
            using (context)
            {
                var        controller = new LineaFacturasController(context);
                Menu       menu       = new Menu();
                Habitacion habitacion = new Habitacion();
                Factura    factura    = null;
                int        cantidad   = 1;
                bool       exResult   = false;
                // Act
                bool result = await controller.CrearLineaMenu(menu, cantidad, factura, habitacion);

                //Assert
                Assert.IsType <bool>(result);
                Assert.Equal(exResult, result);
            }
        }
Exemple #3
0
        public async Task CrearLineaMenu_Success()
        {
            // Arrange
            using (context)
            {
                var  controller = new LineaFacturasController(context);
                Menu menu       = new Menu
                {
                    idServicio = 1,
                    horaInicio = new DateTime(2001, 12, 13, 13, 00, 00),
                    horaFin    = new DateTime(2001, 12, 13, 16, 00, 00),
                    precio     = 10F
                };
                int     cantidad = 1;
                Factura factura  = new Factura {
                    idFactura = 1
                };
                Habitacion habitacion = new Habitacion {
                    numero = 101
                };
                bool         exResult = true;
                LineaFactura exLF     = new LineaFactura {
                    idLineaFactura = 1, Factura = factura, precio = menu.precio
                };
                ReservaServicio exRS = new ReservaServicio
                {
                    idReservaServicio = 1,
                    Habitacion        = habitacion,
                    fechaInicio       = new DateTime(2016, 10, 20, 13, 00, 00),
                    fechaFin          = new DateTime(2016, 10, 20, 16, 00, 00),
                    LineaFactura      = exLF,
                    Servicio          = menu
                };
                exLF.ReservaServicio = exRS;
                IEnumerable <LineaFactura> exLFModel = new List <LineaFactura> {
                    exLF
                };
                IEnumerable <ReservaServicio> exRSModel = new List <ReservaServicio> {
                    exRS
                };

                SystemTime.Now = () => new DateTime(2016, 10, 20, 14, 00, 00);
                // Act
                bool result = await controller.CrearLineaMenu(menu, cantidad, factura, habitacion);

                //Assert
                Assert.IsType <bool>(result);
                Assert.Equal(exResult, result);

                IEnumerable <ReservaServicio> rsModel = context.ReservaServicio.ToList <ReservaServicio>();
                IEnumerable <LineaFactura>    lfModel = context.LineaFactura.ToList <LineaFactura>();
                Assert.Equal(exRSModel,
                             rsModel,
                             Comparer.Get <ReservaServicio>((rs1, rs2) => rs1.idReservaServicio == rs2.idReservaServicio &&
                                                            rs1.Habitacion.numero == rs2.Habitacion.numero &&
                                                            rs1.LineaFactura.idLineaFactura == rs2.LineaFactura.idLineaFactura &&
                                                            rs1.Servicio.idServicio == rs2.Servicio.idServicio &&
                                                            rs1.fechaInicio.Equals(rs2.fechaInicio) &&
                                                            rs1.fechaFin.Equals(rs2.fechaFin)));
                Assert.Equal(exLFModel,
                             lfModel,
                             Comparer.Get <LineaFactura>((lf1, lf2) => lf1.idLineaFactura == lf2.idLineaFactura &&
                                                         lf1.precio == lf2.precio &&
                                                         lf1.Factura.idFactura == lf2.Factura.idFactura &&
                                                         lf1.ReservaServicio.idReservaServicio == lf2.ReservaServicio.idReservaServicio
                                                         ));
            }
        }