Quantcast
Channel: Fluent Validation for .NET
Viewing all articles
Browse latest Browse all 1917

Commented Issue: Issues in ShouldHaveValidationErrorFor and ShouldNotHaveValidationErrorFor methods [7095]

$
0
0
We cannot use ShouldHaveValidationErrorFor and ShouldNotHaveValidationErrorFor methods for nested properties. For example, for tested class has a property of another class. For example, we cannot write:
validator.ShouldHaveValidationErrorFor(x => x.AddNewComment.CommentText, model);
(an exception is thrown)

For more info please get the latest development version of nopCommerce (open source shopping cart). It's not an official release yet, so get it here http://nopcommerce.codeplex.com/SourceControl/list/changesets . Open Nop.Web.MVC.Tests project, then \Public\Validators\Blogs\BlogPostValidatorTests.cs unit test file. Look at its implementation
Comments: Thanks for reply. I know, I have looked into source code. But how about adding for support these child properties? It's weird that you can write validation rules for such child properties, but cannot write unit tests for them.

Viewing all articles
Browse latest Browse all 1917

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>