public async Task PutPersonInfo_BadRequestResult_400_When_Id_not_equal_PersonInfo_Id() { //Arrange var testPersonInfo = GetTestPersonInfoAsync().Result; var otherId = 0; var _contextMock = new Mock <PeopleDWContext>(); //Act var personInfoesController = new PersonInfoesController(_contextMock.Object); var actionResult = await personInfoesController .PutPersonInfo(otherId, testPersonInfo); //Assert var badRequestResult = Assert.IsType <BadRequestResult>(actionResult); Assert.Equal(400, badRequestResult.StatusCode); }
public async Task PutPersonInfo_BadRequestObjectResult_400_When_ModelState_not_valid() { //Arrange var testPersonInfo = GetTestPersonInfoAsync().Result; var anyId = testPersonInfo.IdPeople; var _contextMock = new Mock <PeopleDWContext>(); //Act var personInfoesController = new PersonInfoesController(_contextMock.Object); personInfoesController.ModelState.AddModelError("Key", "Test_Error"); var actionResult = await personInfoesController .PutPersonInfo(anyId, testPersonInfo); //Assert var badRequestObjectResult = Assert.IsType <BadRequestObjectResult>(actionResult); Assert.Equal(400, badRequestObjectResult.StatusCode); }