public void TestCreateUser() { var groupTeamMethods = new GroupTeamMethods(); var userTeamMethods = new UserTeamMethods(); // crio o objeto que irei enviar para o método de criar user var userObject = new UserTeamDTO { CreateDate = DateTime.Now, FullName = "123 de Oliveira 4", GroupTeamId = groupTeamMethods.Display().LastOrDefault().GroupTeamId, IsEnabled = true, Login = "******", Password = "******" }; // guardo quantos users tinham antes de eu criar o novo user int usersBefore = userTeamMethods.Display().Count; // crio o novo user userTeamMethods.Create(userObject); // guardo quantos users tem depois int usersAfter = userTeamMethods.Display().Count; // verifico se a quantidade de users antes + 1 é igual a quantidade de users agora // se sim, foi criado direitinho Assert.IsTrue((usersBefore) + 1 == usersAfter); }
public void TestList() { var groupTeamMethods = new GroupTeamMethods(); // vejo se a lista da tabela não está nula // se não estiver, é porque o display está funcionando var listTest = groupTeamMethods.Display(); Assert.IsNotNull(listTest); }
public IHttpActionResult GetById(int id) { var groupTeamMethods = new GroupTeamMethods(); var found = groupTeamMethods.Find(id); if (found == null) { return BadRequest("The item could not be found."); } else { return Ok(found); } }
public IHttpActionResult Delete(int id) { var groupTeamMethods = new GroupTeamMethods(); if (groupTeamMethods.Find(id) == null) { return BadRequest("The item doesn't exist."); } else { groupTeamMethods.Delete(id); return ResponseMessage(new HttpResponseMessage(HttpStatusCode.NoContent)); } }
public IHttpActionResult Post(GroupTeamDTO groupTeam) { var groupTeamMethods = new GroupTeamMethods(); if (groupTeam == null) { return BadRequest(); } else { groupTeamMethods.Create(groupTeam); var uri = new Uri("/api/group", UriKind.Relative); return Created(uri,"Group created with success."); } }
public void TestDelete() { var groupTeamMethods = new GroupTeamMethods(); var lastItemOfTheList = groupTeamMethods.Display().LastOrDefault().GroupTeamId; // deleto o item que quero groupTeamMethods.Delete(lastItemOfTheList); // tento encontrar o item que deletei var responseFind = groupTeamMethods.Find(lastItemOfTheList); // se for nulo, significa que o item foi apagado e o método funciona Assert.IsNull(responseFind); }
public IHttpActionResult GetById(int id) { var groupTeamMethods = new GroupTeamMethods(); var found = groupTeamMethods.Find(id); if (found == null) { return(BadRequest("The item could not be found.")); } else { return(Ok(found)); } }
public IHttpActionResult Delete(int id) { var groupTeamMethods = new GroupTeamMethods(); if (groupTeamMethods.Find(id) == null) { return(BadRequest("The item doesn't exist.")); } else { groupTeamMethods.Delete(id); return(ResponseMessage(new HttpResponseMessage(HttpStatusCode.NoContent))); } }
public IHttpActionResult Post(GroupTeamDTO groupTeam) { var groupTeamMethods = new GroupTeamMethods(); if (groupTeam == null) { return(BadRequest()); } else { groupTeamMethods.Create(groupTeam); var uri = new Uri("/api/group", UriKind.Relative); return(Created(uri, "Group created with success.")); } }
public IHttpActionResult Put(int id, GroupTeamDTO groupToUpdate) { var update = new GroupTeamMethods(); if (update.Find(id) == null) { return(BadRequest("The item could not be found")); } else { update.Update(id, groupToUpdate); #warning Resposta com objeto genérico <T> //var result = new HttpResponseMessage<GroupTeamDTO>(null, HttpStatusCode.NotFound); //var responseMSg = Request.CreateResponse<GroupTeamDTO>(HttpStatusCode.OK, groupToUpdate); return(ResponseMessage(new HttpResponseMessage(HttpStatusCode.NoContent))); //return ResponseMessage(responseMSg); } }
public void TestUpdate() { var update = new GroupTeamMethods(); // crio o objeto de grupo para atualizar var groupTeam = new GroupTeamDTO { Name = "HUE BR", Description = "FESTA" }; var lastItemOfTheList = update.Display().LastOrDefault().GroupTeamId; // atualizo na tabela passando o item que quero modificar // e o objeto que modifiquei update.Update(lastItemOfTheList, groupTeam); // guardo o objeto que atualizei var responseFind = update.Find(lastItemOfTheList); // verifico se o item que criei possui a o mesmo nome do objeto que mandei // se sim, significa que o update está ok Assert.IsTrue(responseFind.Name == groupTeam.Name); }
public void TestCreateGroup() { var groupTeamMethods = new GroupTeamMethods(); // crio o objeto de grupo var groupTeam = new GroupTeamDTO { Name = "Test Name", CreateDate = DateTime.Now, Description = "Testing the description" }; // vejo quantos items da tabela grupo tinham antes int totalBefore = groupTeamMethods.Display().Count; // crio no grupo passando o objeto que criei groupTeamMethods.Create(groupTeam); // vejo quantos items tem na tabela depois int totalAfter = groupTeamMethods.Display().Count; // verifico se o total antes+1 é o mesmo que o total depois // se for, significa que foi criado Assert.IsTrue((totalBefore) + 1 == totalAfter); }
public IHttpActionResult Get() { var groupTeamMethods = new GroupTeamMethods(); return Ok(groupTeamMethods.Display()); }
public IHttpActionResult Put(int id, GroupTeamDTO groupToUpdate) { var update = new GroupTeamMethods(); if (update.Find(id) == null) { return BadRequest("The item could not be found"); } else { update.Update(id, groupToUpdate); #warning Resposta com objeto genérico <T> //var result = new HttpResponseMessage<GroupTeamDTO>(null, HttpStatusCode.NotFound); //var responseMSg = Request.CreateResponse<GroupTeamDTO>(HttpStatusCode.OK, groupToUpdate); return ResponseMessage(new HttpResponseMessage(HttpStatusCode.NoContent)); //return ResponseMessage(responseMSg); } }
public IHttpActionResult Get() { var groupTeamMethods = new GroupTeamMethods(); return(Ok(groupTeamMethods.Display())); }