AnthonySteele / MvcRouteTester

A library for unit testing ASP MVC route tables for both Web and API Routes
Apache License 2.0
105 stars 43 forks source link

Allow model validation to ignore certain properties on the models based on the property attributes. #27

Closed krimsonkla closed 11 years ago

krimsonkla commented 11 years ago

This is especially useful in cases where you have properties which should not be deserialize or serialized in a webapi. Example Attributes: JsonIgnoreAttribute - non serialized property in a json webapi BSonIgnoreAttriute - mongo database ignored property

The setup for this uses a static prop on the PropertyReader. This path was taken to allow single setup within a TestFixture. A more fluent approach became rather wordy in each test.

Example Usage: PropertyReader.IgnoreAttributes(new[] { typeof(JsonIgnoreAttribute), typeof(BsonIgnoreAttribute) });

krimsonkla commented 11 years ago

Failing unit tests

krimsonkla commented 11 years ago

Pushed test fix.

AnthonySteele commented 11 years ago

Thanks for the pull requests, always good to see new features appear by magic!

I've been away, so I haven't had a chance to look at them yet. I'm back and will try my best to work them in over the next few days. Sorry about the delay.

AnthonySteele commented 11 years ago

I am refactoring this a bit. I prefer RouteAssert.IgnoreAttributes to be the public interface to this. It's easier to change if need be if the facade class is the only one that users work with

krimsonkla commented 11 years ago

Makes sense, I didn't really like the location I added it to. Didn't really feel right, but wasn't familiar enough with the code. Glad you approve of the feature!