Writing Unit Test for Model Validation

It is a pretty common pattern to validate your Web Action model using ModelState.IsValid method. For example, public async Task<UpdateUserProfileResponse> UpdateUser(UpdateUserProfileRequest user) { if (ModelState.IsValid) { // Valid Model, do your job } else { // Send response indicating invalid model } } A pretty useful pattern, as it makes use of the DataAnnotations to validate and provide meaning … Continue reading Writing Unit Test for Model Validation