public async Task Put() { //Arrange var get = await controller.Get(1); var okgetResult = Assert.IsType <OkObjectResult>(get); var entity = Assert.IsType <landownercontact>(okgetResult.Value); var newEntity = new landownercontact(); newEntity.fname = "jane"; newEntity.lname = "smith"; //should test the equals Equatable for all these too var huh = entity.Equals(newEntity); entity.fname = "test"; entity.lname = "Edit"; // Act var response = await controller.Put(1, entity); // Assert var okResult = Assert.IsType <OkObjectResult>(response); var result = Assert.IsType <landownercontact>(okResult.Value); Assert.Equal(entity.fname, result.fname); }
public async Task <IActionResult> Put(int id, [FromBody] landownercontact 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 = DateTime.Now; entity.last_updated_by = loggedInMember.member_id; return(Ok(await agent.Update <landownercontact>(id, entity))); } catch (Exception ex) { return(await HandleExceptionAsync(ex)); } }
public async Task Post() { //Arrange var entity = new landownercontact() { fname = "Test", lname = "Post" }; //Act var response = await controller.Post(entity); // Assert var okResult = Assert.IsType <OkObjectResult>(response); var result = Assert.IsType <landownercontact>(okResult.Value); Assert.Equal("Test", result.fname); Assert.Equal("Post", result.lname); }