Пример #1
0
        public void GetReporteConElementoOk()
        {
            var reporteMock               = new Mock <IGenerarReporte>(MockBehavior.Strict);
            var logicMock                 = new Mock <IReserva>(MockBehavior.Strict);
            var logicMockHospedaje        = new Mock <IHospedaje>(MockBehavior.Strict);
            ReservasController controller = new ReservasController(logicMock.Object, logicMockHospedaje.Object);

            PuntoTuristico punto = new PuntoTuristico()
            {
                Id = 0, Nombre = "Test"
            };
            DatosReporte datos = new DatosReporte()
            {
                PuntoId = punto.Id
            };

            logicMock.Setup(x => x.ObtenerTodos())
            .Returns(new List <Reserva>()
            {
                new Reserva()
                {
                    Id = 0, Hospedaje = new Hospedaje()
                    {
                        Id = 0, PuntoTuristico = punto
                    }, NombreTurista = "Test"
                }
            });

            reporteMock.Setup(x => x.GenerarReporte(datos)).Returns(It.IsAny <List <CantReservasPorHospedaje> >());

            var result   = controller.GetReporte(datos);
            var okResult = result as OkObjectResult;

            logicMock.VerifyAll();
        }
Пример #2
0
        public void GetReporteSinFecha()
        {
            var reporteMock               = new Mock <IGenerarReporte>(MockBehavior.Strict);
            var logicMock                 = new Mock <IReserva>(MockBehavior.Strict);
            var logicMockHospedaje        = new Mock <IHospedaje>(MockBehavior.Strict);
            ReservasController controller = new ReservasController(logicMock.Object, logicMockHospedaje.Object);

            logicMock.Setup(x => x.ObtenerTodos()).Returns(new List <Reserva>());
            reporteMock.Setup(x => x.GenerarReporte(It.IsAny <DatosReporte>())).Throws(new FechaVaciaException());

            var result   = controller.GetReporte(It.IsAny <DatosReporte>());
            var okResult = result as BadRequestObjectResult;

            logicMock.VerifyAll();
        }