public void Delete_IDExistente_ReturnsOK() { // Arrange var testID = 20; // Act var okResponse = _controller.Delete(testID); // Assert Assert.IsType <OkResult>(okResponse); }
public void Delete() { // Arrange UsuariosController controller = new UsuariosController(); // Act controller.Delete(5); // Assert }
public void DeleteUsuarioOk() { var logicMock = new Mock <IUsuario>(MockBehavior.Strict); UsuariosController controller = new UsuariosController(logicMock.Object); logicMock.Setup(x => x.BorrarUsuario(It.IsAny <int>())); var result = controller.Delete(It.IsAny <int>()); var okResult = result as OkObjectResult; logicMock.VerifyAll(); }
public void Post() { this.DataCreate(); UsuarioModel model = new UsuarioModel() { Email = "*****@*****.**", Nome = "Roberto Justus", Senha = "O@prendiz" }; // Act var result = _controller.Post(model); // Assert Assert.NotNull(result); var item = Assert.IsType <Resultado>(result); Assert.True(item.Sucesso); Assert.Empty(item.Inconsistencias); var list = _controller.Get(); Assert.NotNull(list); Assert.NotEmpty(list); var items = Assert.IsType <List <UsuarioModel> >(list); Assert.Equal(2, items.Count); //Back var usuario = items.FirstOrDefault(p => p.Email == "*****@*****.**"); var removeResult = _controller.Delete(usuario.ID); Assert.NotNull(removeResult); var removeItem = Assert.IsType <Resultado>(removeResult); Assert.True(removeItem.Sucesso); Assert.Empty(removeItem.Inconsistencias); }
public void DeleteUsuarioNoExiste() { var logicMock = new Mock <IUsuario>(MockBehavior.Strict); UsuariosController controller = new UsuariosController(logicMock.Object); logicMock.Setup(x => x.BorrarUsuario(It.IsAny <int>())).Throws(new EntidadNoExisteExcepcion()); var result = controller.Delete(It.IsAny <int>()); var okResult = result as NotFoundObjectResult; logicMock.VerifyAll(); Assert.AreEqual(404, okResult.StatusCode); }
public void DeleteUsuario_UsuarioEditado() { var context = new UsuariosContextTest(); var item = GetDemoUsuario(); context.Usuarios.Add(item); var controller = new UsuariosController(context); var result = controller.Delete(1) as OkNegotiatedContentResult <Usuarios>; Assert.IsNull(result); }
public void Delete() { Usuario usuario = new Usuario() { Id = 1, Nome = "ALEXANDRE", Telefone = 222222222 }; mockRepository.Setup(r => r.GetUsuario(It.IsAny <int>())).Returns(usuario); controller = new UsuariosController(mockRepository.Object); ViewResult result = controller.Delete(1) as ViewResult; Assert.IsNotNull(result); }
public void Delete_Usuario() { //Arrange UsuariosController controller = new UsuariosController(); Usuario usuario = new Usuario() { Apellido = "ApellidoAutoGenerado", Email = "*****@*****.**", Password = "******", Nombre = "NombreAutoGenerado" }; controller.Post(usuario); //Act controller.Delete(usuario.UsuarioId); //Assert var check = controller.Get(usuario.UsuarioId); Assert.IsNull(check); }
public void Cria_Consulta_Deleta_Usuario_ReturnsTrue() { #region Cria Usuário var retPost = (OkObjectResult)userTest.Post(new Business.View.UsuarioView() { Login = "******", Nome = "Usuário de teste 1", Email = "*****@*****.**" }); Assert.True(retPost.StatusCode == 200); #endregion #region Consulta Todos var retGetAll = userTest.Get(); var usuListView = JsonConvert.DeserializeObject <List <Business.View.UsuarioView> >(retGetAll.ToString()); Assert.True(usuListView.Count > 0); #endregion #region Consulta Usuário var retGet = userTest.GetByLogin("UsuarioTeste1"); var usuView = JsonConvert.DeserializeObject <Business.View.UsuarioView>(retGet.ToString()); Assert.True(usuView?.Id > 0); #endregion #region Delete Id inválido Usuário var retDel = userTest.Delete(0); bool condVal = false; try { var valOk = (NotFoundObjectResult)retDel; condVal = valOk.StatusCode == 404; } catch { condVal = false; } Assert.True(condVal); #endregion #region Delete Usuário if (usuView?.Id != 0) { retDel = userTest.Delete(usuView.Id); condVal = false; try { var valOk = (OkObjectResult)retDel; condVal = valOk.StatusCode == 200; } catch { condVal = false; } Assert.True(condVal); } #endregion }