I'm having trouble figuring out a way to unit test a WPF style selector.
My selector looks like:
public class ListViewItemStyleSelector : StyleSelector
{
public override Style SelectStyle(object item, DependencyObject container)
{
var listView = ItemsControl.ItemsControlFromItemContainer(container) as ListView;
Style style;
var index = listView.ItemContainerGenerator.IndexFromContainer(container);
if (index % 2 == 0)
style = (Style)listView.FindResource("listViewItemStyle");
else
style = (Style)listView.FindResource("listViewAlternatingItemStyle");
return style;
}
}
I'd have to think there would be a way to mimic the binding process and then assert on the style that comes out. Any ideas, or is this an area of WPF that can't be faked out?
I'm using Rhino Mocks for my mocking framework, but I'm not opposed to hand rolling fakes if need be.