My unit tests:
[Test]publicvoid DeleteListReleaseViewModel_ReleaseIsNotSelected_ReturnsIsNotValid() {new DeleteReleaseListViewModelValidator().ShouldHaveValidationErrorFor(x => x.SelectedId, (int?)null); } [Test] publicvoid DeleteListReleaseViewModel_ReleaseIsSelected_ReturnsIsValid() {new DeleteReleaseListViewModelValidator().ShouldNotHaveValidationErrorFor(x => x.SelectedId, new DeleteReleaseListViewModel() { SelectedId = 1 }); }
Both tests succeed. But when I do manual testing then in the controller the ModelState is true although the SelectedId is NULL.
Why the difference in the behavior?