public async Task Put() { //Arrange var get = await controller.Get(1); var okgetResult = Assert.IsType <OkObjectResult>(get); var entity = Assert.IsType <horizontal_collect_methods>(okgetResult.Value); var newEntity = new horizontal_collect_methods(); newEntity.hcollect_method = "handheld GPS"; //should test the equals Equatable for all these too var huh = entity.Equals(newEntity); entity.hcollect_method = "testEdit"; //Act var response = await controller.Put(1, entity); // Assert var okResult = Assert.IsType <OkObjectResult>(response); var result = Assert.IsType <horizontal_collect_methods>(okResult.Value); Assert.Equal(entity.hcollect_method, result.hcollect_method); }
public async Task <IActionResult> Put(int id, [FromBody] horizontal_collect_methods entity) { try { if (id < 0 || !isValid(entity)) { return(new BadRequestResult()); } return(Ok(await agent.Update <horizontal_collect_methods>(id, entity))); } catch (Exception ex) { return(await HandleExceptionAsync(ex)); } }
public async Task <IActionResult> Post([FromBody] horizontal_collect_methods entity) { try { if (!isValid(entity)) { return(new BadRequestResult()); } //sm(agent.Messages); return(Ok(await agent.Add <horizontal_collect_methods>(entity))); } catch (Exception ex) { //sm(agent.Messages); return(await HandleExceptionAsync(ex)); } }
public async Task Post() { //Arrange var entity = new horizontal_collect_methods() { hcollect_method = "TestPost" }; //Act var response = await controller.Post(entity); // Assert var okResult = Assert.IsType <OkObjectResult>(response); var result = Assert.IsType <horizontal_collect_methods>(okResult.Value); Assert.Equal("TestPost", result.hcollect_method); }