Пример #1
0
        public void DeleteUsuario()
        {
            IQueryable <Usuario> usuarios = _controller.GetUsuarios();
            var result = _controller.DeleteUsuario(7) as System.Web.Http.Results.OkNegotiatedContentResult <Usuario>;

            Assert.IsNotNull(usuarios);
            //Assert.IsInstanceOfType(result.Content, typeof(Usuario));
            //Assert.AreEqual(7, result.Content.Id);
        }
Пример #2
0
        public void DeleteUsuario()
        {
            mockRepository.Setup(r => r.GetUsuario(It.IsAny <int>())).Returns(usuario);
            mockRepository.Setup(r => r.DeleteUsuario(It.IsAny <int>())).Returns(usuario);
            mockController.Setup(c => c.DeleteUsuario(It.IsAny <int>()));

            var _controller = new UsuariosController(mockController.Object, mockRepository.Object);
            var result      = _controller.DeleteUsuario(1) as System.Web.Http.Results.OkNegotiatedContentResult <Usuario>;

            Assert.IsInstanceOfType(result.Content, typeof(Usuario));
            Assert.AreEqual(1, result.Content.Id);
        }
Пример #3
0
        public async Task TestDeleteReturnsOk()
        {
            // Arrange
            var mockService = new Mock <IUsuarioService>();
            var controller  = new UsuariosController(mockService.Object);

            var usuario = this.MockUsuarioService.GetPorId(1);
            // Act
            var result = await controller.DeleteUsuario(1) as OkObjectResult;

            mockService.Verify(r => r.Remover(usuario.Id.Value), Times.Once());
        }
Пример #4
0
        public async void FailDelete()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <AlpmysContext>()
                          .UseInMemoryDatabase("FailDeleteEvent")
                          .Options;
            AlpmysContext      context    = new AlpmysContext(options);
            UsuariosController controller = new UsuariosController(context);

            // Act
            var result = await controller.DeleteUsuario(10);

            // Assert
            Assert.IsType <NotFoundResult>(result);
        }
Пример #5
0
        public async void Delete()
        {
            // Arrange
            var options = new DbContextOptionsBuilder <AlpmysContext>()
                          .UseInMemoryDatabase("DeleteEvent")
                          .Options;
            AlpmysContext      context    = new AlpmysContext(options);
            UsuariosController controller = new UsuariosController(context);
            Usuario            u          = new Usuario();

            u.Id    = 9;
            u.Email = "*****@*****.**";

            // Act
            await controller.PostUsuario(u);

            await controller.DeleteUsuario(9);

            // Assert
            Assert.Equal(0, context.Evento.Count());
        }