umco / umbraco-ditto

Ditto - the friendly view-model mapper for Umbraco
http://our.umbraco.org/projects/developer-tools/ditto
MIT License
79 stars 33 forks source link

Testing IPublishedContent with IsEnumerableOfType extension method #138

Closed leekelleher closed 8 years ago

leekelleher commented 9 years ago

Hey @JimBobSquarePants, here's one for you :smirk_cat:

Whilst experimenting with returning collections of a custom IPublishedContent class, Ditto wouldn't attempt to cast/map them any further.

I set up a quick unit-test to see if this was the case... (where PublishedContentMock is a custom implementation of IPublishedContent)

typeof(IEnumerable<Mocks.PublishedContentMock>).IsEnumerableOfType(typeof(IPublishedContent))

Should this be true or false?


I've added in a fix that swaps around the params for the IsAssignableFrom check.

JimBobSquarePants commented 9 years ago

Yeah, in my mind that should return true. I'll double check against the tests etc to make sure your fix doesn't have any unforseen side effects.

leekelleher commented 9 years ago

Thanks @JimBobSquarePants!

This came about when I was reviewing a Merchello/Ditto workshop implementation. Merchello has an IProductContent which derives from IPublishedContent, which "should" play nicely with Ditto, but it wasn't. :blush:

The other unit-tests all pass, which either means the patch is cool... or we're missing test scenarios :wink: (gotta test 'em all!)

leekelleher commented 8 years ago

@JimBobSquarePants No pressure, just curious if you've had chance to look this one?

JimBobSquarePants commented 8 years ago

Sorry... Yeah, looks good to me!

leekelleher commented 8 years ago

Cool, merged in!