예제 #1
0
        public void PostReservaDatosNull()
        {
            var logicMock                 = new Mock <IReserva>(MockBehavior.Strict);
            var logicMockHospedaje        = new Mock <IHospedaje>(MockBehavior.Strict);
            ReservasController controller = new ReservasController(logicMock.Object, logicMockHospedaje.Object);
            DateTime           checkIn    = new DateTime(2020, 10, 9);
            DateTime           checkOut   = new DateTime(2020, 10, 11);
            const int          intTest    = 1;
            CantHuespedes      huespedes  = new CantHuespedes()
            {
                CantJubilados = 0,
                CantAdultos   = intTest,
                CantBebes     = intTest,
                CantNinios    = intTest,
            };

            HospedajeFiltro filtro = new HospedajeFiltro()
            {
                Huespedes = huespedes,
                CheckIn   = checkIn,
                CheckOut  = checkOut,
            };
            ObjetoPostReserva objeto = new ObjetoPostReserva()
            {
                HospedajeId = intTest, Datos = null, Filtro = filtro
            };

            var result   = controller.Post(intTest, objeto);
            var okResult = result as BadRequestObjectResult;

            logicMock.VerifyAll();
        }
예제 #2
0
        public void PostReservaFiltroNull()
        {
            string             stringPrueba       = "test";
            var                logicMock          = new Mock <IReserva>(MockBehavior.Strict);
            var                logicMockHospedaje = new Mock <IHospedaje>(MockBehavior.Strict);
            ReservasController controller         = new ReservasController(logicMock.Object, logicMockHospedaje.Object);
            DateTime           checkIn            = new DateTime(2020, 10, 9);
            DateTime           checkOut           = new DateTime(2020, 10, 11);
            const int          intTest            = 1;
            DatosUsuario       datos = new DatosUsuario()
            {
                Nombre   = stringPrueba,
                Apellido = stringPrueba,
                Mail     = stringPrueba
            };
            ObjetoPostReserva objeto = new ObjetoPostReserva()
            {
                HospedajeId = intTest, Datos = datos, Filtro = null
            };

            var result   = controller.Post(intTest, objeto);
            var okResult = result as BadRequestObjectResult;

            logicMock.VerifyAll();
        }
예제 #3
0
        public void PostReservaYaExisteId()
        {
            string             stringPrueba       = "test";
            var                logicMock          = new Mock <IReserva>(MockBehavior.Strict);
            var                logicMockHospedaje = new Mock <IHospedaje>(MockBehavior.Strict);
            ReservasController controller         = new ReservasController(logicMock.Object, logicMockHospedaje.Object);
            DateTime           checkIn            = new DateTime(2020, 10, 9);
            DateTime           checkOut           = new DateTime(2020, 10, 11);
            const int          intTest            = 1;
            CantHuespedes      huespedes          = new CantHuespedes()
            {
                CantJubilados = 0,
                CantAdultos   = intTest,
                CantBebes     = intTest,
                CantNinios    = intTest,
            };

            HospedajeFiltro filtro = new HospedajeFiltro()
            {
                Huespedes = huespedes,
                CheckIn   = checkIn,
                CheckOut  = checkOut,
            };

            DatosUsuario datos = new DatosUsuario()
            {
                Nombre   = stringPrueba,
                Apellido = stringPrueba,
                Mail     = stringPrueba
            };

            logicMock.Setup(x => x.Reserva(filtro, intTest, datos)).Returns(It.IsAny <Reserva>());
            logicMock.Setup(x => x.AgregarReserva(It.IsAny <Reserva>())).Throws(new YaExisteLaEntidadExcepcion());

            ObjetoPostReserva objeto = new ObjetoPostReserva()
            {
                HospedajeId = intTest, Datos = datos, Filtro = filtro
            };

            var result   = controller.Post(intTest, objeto);
            var okResult = result as BadRequestObjectResult;

            logicMock.VerifyAll();
        }