Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Fixing data annotations unit tests #1471

Merged
merged 2 commits into from Mar 2, 2014
Merged

Fixing data annotations unit tests #1471

merged 2 commits into from Mar 2, 2014

Conversation

xt0rted
Copy link
Contributor

@xt0rted xt0rted commented Mar 2, 2014

The first commit turns the tests back on but they don't pass because the validation refactoring removed class level attribute support. The second commit tries to add this back in.

From what I know ASP.NET MVC adds class level errors to the results with an empty member name which is what I did here. This also required modifying the custom attribute in the tests to return a member name otherwise the tests still failed.

Another option is to modify the OopsAdapter and override the Validate function like this

yield return new ModelValidationError(new[] { string.Empty }, result.ErrorMessage);

I think this is the better of the two options, I just don't like how the rest of the function is duplicated. I had to do this when implementing an adapter for the CompareAttribute so maybe this could be refactored a bit more to remove the duplication?

I still need to make the change to handle display names as per #1469 but I was looking for feedback on these changes first.

@thecodejunkie thecodejunkie merged commit 9f207dd into NancyFx:master Mar 2, 2014
@thecodejunkie
Copy link
Member

Thanks! Pulled it in locally and refactored the method a bit

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants