Hi,
I have a a class called "ViewFactory" and this class should deliver the right view
right now it has only one method (and it will grow) which I want to write a unit test against.
the class looks like this...
public class ViewFactory
{
[ImportMany(AllowRecomposition=true)]
IEnumerable<ExportFactory<DependencyObject, IViewMetaData>> Views { get; set; }
public DependencyObject GetViewByName(string name)
{
DependencyObject view = null;
try
{
view = Views.Where(v => v.Metadata.ViewName == name).FirstOrDefault().CreateExport().Value;
return view;
}
catch (Exception ex)
{
return view;
}
}
}
what I do want is to test my method but don't know how to do it because the List of Views is composed on runtime...
I want to test if I get a view for a valid name and I also want to test if I get null if I have an invalid name
What would be the right way?