Created
February 10, 2012 03:29
-
-
Save linuxbender/1786130 to your computer and use it in GitHub Desktop.
How to Unit Test Data Annotation Validators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestMethod] | |
public void Description_Should_Be_Required() | |
{ | |
Expression<Func<MenuCategoryBusinessObject, object>> expression = | |
o => o.Description; | |
var me = expression.Body as MemberExpression; | |
var att = (RequiredAttribute[])me.Member | |
.GetCustomAttributes(typeof(RequiredAttribute), false); | |
att.Length.ShouldEqual(1); | |
} | |
ModelBinders.Binders.DefaultBinder = new DataAnnotationsModelBinder(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment