public async Task Put() { //Arrange var get = await controller.Get(1); var okgetResult = Assert.IsType <OkObjectResult>(get); var entity = Assert.IsType <objective_point>(okgetResult.Value); var newEntity = new objective_point(); newEntity.name = "not Defined"; newEntity.description = "something"; newEntity.date_established = new DateTime(); newEntity.site_id = 1; newEntity.vdatum_id = 11; newEntity.latitude_dd = 43.33; newEntity.longitude_dd = -88.22; newEntity.op_type_id = 1; //should test the equals Equatable for all these too var huh = entity.Equals(newEntity); entity.name = "testEdit"; //Act var response = await controller.Put(1, entity); // Assert var okResult = Assert.IsType <OkObjectResult>(response); var result = Assert.IsType <objective_point>(okResult.Value); Assert.Equal(entity.name, result.name); }
public async Task <IActionResult> Put(int id, [FromBody] objective_point entity) { try { if (id < 0 || !isValid(entity)) { return(new BadRequestResult()); } var loggedInMember = LoggedInUser(); if (loggedInMember == null) { return(new BadRequestObjectResult("Invalid input parameters")); } entity.last_updated_by = loggedInMember.member_id; entity.last_updated = DateTime.Now; return(Ok(await agent.Update <objective_point>(id, entity))); } catch (Exception ex) { return(await HandleExceptionAsync(ex)); } }
public async Task Post() { //Arrange var entity = new objective_point() { name = "TestPost", description = "testpost", date_established = new DateTime(), site_id = 2, vdatum_id = 22, latitude_dd = 44.44, longitude_dd = -89.33, op_type_id = 2 }; //Act var response = await controller.Post(entity); // Assert var okResult = Assert.IsType <OkObjectResult>(response); var result = Assert.IsType <objective_point>(okResult.Value); Assert.Equal("TestPost", result.name); }