public async Task ReturnBadRequestOnUpdateWhenModelNotValid() { // Arrange _controller.ModelState.AddModelError("someFakeError", "fakeError message"); var answers = new Faker <AnswersUpdateModel>() .RuleFor(s => s.Id, v => ++ v.IndexVariable) .RuleFor(s => s.UserId, v => v.IndexVariable) .RuleFor(s => s.OptionId, v => v.IndexVariable) .Generate(); var expected = new Faker <AnswersBaseModel>() .RuleFor(s => s.Id, v => ++ v.IndexVariable) .RuleFor(s => s.UserId, v => v.IndexVariable) .RuleFor(s => s.OptionId, v => v.IndexVariable) .Generate(); _mockService.Setup(x => x.Update(It.IsAny <AnswersUpdateModel>())) .ReturnsAsync(expected) .Verifiable(); // Act var result = await _controller.Put(answers.Id, answers); // Assert result.Should().BeOfType <BadRequestResult>(); }