public void Post_valid_data_returns_created_at_route() { // arrange var validViewModel = new WorkAssignmentVM(); // act var result = _controller.Post(validViewModel); //assert Assert.IsInstanceOfType(result.Result, typeof(CreatedAtActionResult)); }
public void Put_invalid_data_returns_bad_request() { // Arrange var invalidViewModel = new WorkAssignmentVM(); _controller.ModelState.AddModelError("hourlyWage", "Required"); // Act var result = _controller.Put(invalidViewModel.id, invalidViewModel); // Assert Assert.IsInstanceOfType(result.Result, typeof(BadRequestObjectResult)); }
public void Post_valid_data_returns_new_record_in_data_object() { // arrange var validViewModel = new WorkAssignmentVM(); // act var result = _controller.Post(validViewModel).Result as ObjectResult; var returnedViewModel = UnitTestExtensions.ExtractFromDataObject <WorkAssignmentVM>(result?.Value); //assert Assert.IsInstanceOfType(returnedViewModel, typeof(WorkAssignmentVM)); Assert.IsTrue(UnitTestExtensions.HasDataProperty(result)); }