예제 #1
0
        public async Task DeleteCompany()
        {
            //Arrange

            var BDName  = Guid.NewGuid().ToString();
            var context = BuildContext(BDName);

            var fakecompany = new Empresa()
            {
                Nombre   = "Farenet",
                Ruc      = "123456",
                Telefono = "9852412",
                Correo   = "*****@*****.**",
            };

            context.Empresas.Add(fakecompany);
            await context.SaveChangesAsync();

            var context2 = BuildContext(BDName);

            //Act
            var controller = new ReservasController(context2);

            var response = await controller.Delete(1);

            var cancel = response as StatusCodeResult;

            //Assert
            Assert.AreEqual(404, cancel.StatusCode);

            var context3 = BuildContext(BDName);
            var exist    = await context3.Reservas.FindAsync(1);

            Assert.IsNull(exist);
        }
예제 #2
0
        public void DeleteReservaOk()
        {
            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.BorrarReserva(1));

            var result   = controller.Delete(1);
            var okResult = result as OkObjectResult;

            logicMock.VerifyAll();
        }
예제 #3
0
        public void DeleteReservaNoExiste()
        {
            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.BorrarReserva(1)).Throws(new EntidadNoExisteExcepcion());

            var result   = controller.Delete(1);
            var okResult = result as NotFoundObjectResult;

            logicMock.VerifyAll();

            Assert.AreEqual(404, okResult.StatusCode);
        }
예제 #4
0
        public async Task CancelReservation()
        {
            //Arrange

            var BDName  = Guid.NewGuid().ToString();
            var context = BuildContext(BDName);

            var fakereservation = new Reserva()
            {
                Fecha         = "12/03/20",
                Hora          = "12:00",
                Observaciones = "Color azul",
                VehiculoId    = 1,
                LocalId       = 1
            };

            context.Reservas.Add(fakereservation);
            await context.SaveChangesAsync();

            var context2 = BuildContext(BDName);

            //Act
            var controller = new ReservasController(context2);

            var response = await controller.Delete(1);

            var cancel = response as StatusCodeResult;

            //Assert
            Assert.AreEqual(200, cancel.StatusCode);

            var context3 = BuildContext(BDName);
            var exist    = await context3.Reservas.FindAsync(1);

            Assert.IsNull(exist);
        }