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