Short answer, because we can?
Someone else wrote the unit test in this particular case, I broke it by
adding a style to the shell. I've not looked at what the unit test is
testing. I'd rather have a poorly tested UI/View than no test at all.
It looks like I've found a way to get the test to pass, after much searching
I found a StackOverflow answer that pointed me in the right direction.
var brush = new SolidColorBrush();
application.Resources.Add("NormalGradientBrush", brush);
I've put that in my FixtureSetup so that the resource exists (I don't care
what it actually is, just that it exists enough to create the instance of
the shell).
Read Carl's response, and know the pain you speak of. :)
I spent a day writing a Silverlight unit test on a view (which would become
the basis for future unit tests) and then discovered that the Loaded event
is never raised if the browser is minimised (which on the build server
apparently it is). So the unit test became something that needed to be
manually ran and was quarantined into its own startup page. (thus not being
automated and so never gets run as far as I can tell?) fail.
Also I REALLY miss not having the ability to run all my unit tests in my
test runner of my choice. (currently Resharper's test runner). Spend all my
time wondering if I've run all the unit tests or not. I end up not bothering
and hope that the build server (which it usually does) will catch the broken
tests.
I'll stop now or my reply will become a rant. :)
cheers for the help guys,
Stephen
On Fri, Jun 18, 2010 at 11:26 AM, Steven Nagy <[email protected]>wrote:
> I have no specific answer to your exact problem, however I do have to ask,
> why are you unit testing the shell?
>
> We have patterns like MVVM for just these reasons; you don’t want to test
> the UI but the logic behind it.
>
>
>
> That said you could always add the style to the Shell.Resources instead…
>
> *Steven Nagy
> *Readify | Senior Developer
>
> M: +61 404 044 513 | E: [email protected] | B: azure.snagy.name
>
>
>
> *From:* [email protected] [mailto:[email protected]]
> *On Behalf Of *Stephen Price
> *Sent:* Friday, 18 June 2010 12:47 PM
> *To:* ozWPF
> *Subject:* missing resource
>
>
>
> Hey all,
>
>
>
> Working on some WPF and have hit something I'm sure is easy but can't seem
> to find an answer on.
>
>
>
> I've added a style to the main page and put the new style into a
> MergedDictionary, it works no problems. Where i've come unstuck is there's a
> unit test in another project that creates an instance of the shell. It now
> fails as it can't find the resource. I'm puzzled at how I add it. I tried
> copying the App.xaml file but it gives errors pointing to the fact the
> project doesn't like there being an ApplicationDefinition.
>
>
>
> Just wondering how other people get around this?
>
>
>
> cheers,
>
> Stephen
>
> _______________________________________________
> ozwpf mailing list
> [email protected]
> http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf
>
>
_______________________________________________
ozwpf mailing list
[email protected]
http://prdlxvm0001.codify.net/mailman/listinfo/ozwpf