<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>.NET</title>
        <link>http://www.houseofbilz.com/category/9237.aspx</link>
        <description>.NET</description>
        <language>en-US</language>
        <copyright>Brian Genisio's House Of Bilz</copyright>
        <managingEditor>BrianGenisio@Gmail.Com</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>Adventures in MVVM &amp;ndash; CodeMash Schedule Application</title>
            <link>http://houseofbilz.com/archive/2010/01/11/adventures-in-mvvm-ndash-codemash-schedule-application.aspx</link>
            <description>&lt;p&gt;&lt;a href="http://geekswithblogs.net/HouseOfBilz/archive/2009/05/22/adventures-in-mvvm-ndash-model-view-viewmodel.aspx"&gt;More Adventures in MVVM&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;So, I am getting myself ready to head out to Sandusy, Ohio for three days of nerdy fun at &lt;a href="http://Codemash.org"&gt;CodeMash&lt;/a&gt;.  While I am there, I will be giving my “Introduction to the MVVM Pattern”.  In preparation for this talk, I decided to create a new demo application.  This application is a calendar and session list for the conference.  It is not terribly fancy (I wish I had more time (or talent) to skin it better), but it highlights many of the concepts that I will be speaking about in my presentation.&lt;/p&gt;
&lt;p&gt;The app is a Silverlight 3 project utilizing the Telerik Scheduler control.  This particular control is rather rich, and I was excited to get my hands dirty with it. The ViewModel for the scheduler was primarily responsible for translating session data into something the Telerik control could consume.   The app also includes a session list with a filter panel which is derived from the session data.  This is where the majority of the MVVM code can be found.  The ViewModels for the session list are responsible for dynamically creating and merging filter predicates based on the values in the session list. &lt;/p&gt;
&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/HouseOfBilz/WindowsLiveWriter/AdventuresinMVVMCodeMashScheduleApplicat_1351D/CodeMashSessions.Calendar_2.png"&gt;&lt;img width="442" height="287" border="0" src="http://geekswithblogs.net/images/geekswithblogs_net/HouseOfBilz/WindowsLiveWriter/AdventuresinMVVMCodeMashScheduleApplicat_1351D/CodeMashSessions.Calendar_thumb.png" alt="CodeMashSessions.Calendar" title="CodeMashSessions.Calendar" style="border-width: 0px; display: inline;" /&gt;&lt;/a&gt; &lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/HouseOfBilz/WindowsLiveWriter/AdventuresinMVVMCodeMashScheduleApplicat_1351D/CodeMashSessions.Sessions_2.png"&gt;&lt;img width="436" height="283" border="0" src="http://geekswithblogs.net/images/geekswithblogs_net/HouseOfBilz/WindowsLiveWriter/AdventuresinMVVMCodeMashScheduleApplicat_1351D/CodeMashSessions.Sessions_thumb.png" alt="CodeMashSessions.Sessions" title="CodeMashSessions.Sessions" style="border-width: 0px; display: inline;" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can play with the application at &lt;a href="http://HouseOfBilz.net/CodeMash"&gt;http://HouseOfBilz.net/CodeMash&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;CodeMashSessions Source Code: &lt;a href="http://www.houseofbilz.net/codemash/CodeMashSessions.Source.zip" title="http://www.houseofbilz.net/codemash/CodeMashSessions.Source.zip"&gt;http://www.houseofbilz.net/codemash/CodeMashSessions.Source.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Twitter "Ball of Mud" vs MVVM Source Code: &lt;a href="http://houseofbilz.net/codemash/Twitter-BallOfMud-vs-MVVM.zip"&gt;http://houseofbilz.net/codemash/Twitter-BallOfMud-vs-MVVM.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Slides from "An Introduction to the MVVM Pattern": &lt;a href="http://houseofbilz.net/codemash/MVVM.ppt"&gt;http://houseofbilz.net/codemash/MVVM.ppt&lt;/a&gt;&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=137441"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=137441" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://houseofbilz.com/aggbug/137441.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Brian Genisio's House Of Bilz</dc:creator>
            <guid>http://houseofbilz.com/archive/2010/01/11/adventures-in-mvvm-ndash-codemash-schedule-application.aspx</guid>
            <pubDate>Tue, 12 Jan 2010 02:59:13 GMT</pubDate>
            <wfw:comment>http://houseofbilz.com/comments/137441.aspx</wfw:comment>
            <comments>http://houseofbilz.com/archive/2010/01/11/adventures-in-mvvm-ndash-codemash-schedule-application.aspx#feedback</comments>
            <wfw:commentRss>http://houseofbilz.com/comments/commentRss/137441.aspx</wfw:commentRss>
            <trackback:ping>http://houseofbilz.com/services/trackbacks/137441.aspx</trackback:ping>
        </item>
        <item>
            <title>Binding to Resources in Silverlight/WPF</title>
            <link>http://houseofbilz.com/archive/2009/03/15/binding-to-resources-in-silverlightwpf.aspx</link>
            <description>&lt;a rev="vote-for" href="http://dotnetshoutout.com/Binding-to-Resources-in-SilverlightWPF"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http%3A%2F%2Fwww.houseofbilz.com%2Farchive%2F2009%2F03%2F15%2Fbinding-to-resources-in-silverlightwpf.aspx" /&gt;&lt;/a&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fwww.houseofbilz.com%2farchive%2f2009%2f03%2f15%2fbinding-to-resources-in-silverlightwpf.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.houseofbilz.com%2farchive%2f2009%2f03%2f15%2fbinding-to-resources-in-silverlightwpf.aspx" /&gt;&lt;/a&gt;   &lt;p&gt;This article is describing how to solve the problem in SIlverlight, but the problem can be solved in WPF using the exact same technique.&lt;/p&gt;  &lt;p&gt;So, now it is time to internationalize our application.  I want to use the &lt;a href="http://msdn.microsoft.com/en-us/magazine/cc163609.aspx"&gt;built-in "resx" mechanism&lt;/a&gt; for i18n in .net, so I create myself a resource file and start adding strings to the table:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/HouseOfBilz/WindowsLiveWriter/BindingtoResourcesinSilverlightWPF_C384/image_4.png"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://geekswithblogs.net/images/geekswithblogs_net/HouseOfBilz/WindowsLiveWriter/BindingtoResourcesinSilverlightWPF_C384/image_thumb_1.png" width="600" height="223" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Visual Studio automatically generates the resource class for me, and I am ready to bind to the data in my XAML:&lt;/p&gt;  &lt;pre class="xml" name="code"&gt;&amp;lt;UserControl.Resources&amp;gt;
    &amp;lt;l:i18n x:Key="i18n" /&amp;gt;
&amp;lt;/UserControl.Resources&amp;gt;

&amp;lt;StackPanel x:Name="LayoutRoot" Orientation="Horizontal"&amp;gt;
    &amp;lt;TextBox /&amp;gt;
    &amp;lt;Button Content="{Binding Path=SearchButton, Source={StaticResource i18n}}" /&amp;gt;
&amp;lt;/StackPanel&amp;gt;&lt;/pre&gt;

&lt;p&gt;But I run my application and I get this exception: &lt;strong&gt;Unhandled Error in Silverlight 2 Application AG_E_PARSER_BAD_TYPE&lt;/strong&gt;.  I get this error message because the resx file is set to create my resource class as an "internal" class.  Essentially, the SIlverlight engine doesn't have permission to instantiate a new i18n object, and it dies.&lt;/p&gt;

&lt;p&gt;Fortunately, in Visual Studio 2008, they have given us a way to solve this problem.  In the Resx editor, you can change the protection of the class it generates from internal to public.  So, I do exactly that:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/HouseOfBilz/WindowsLiveWriter/BindingtoResourcesinSilverlightWPF_C384/image_6.png"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="image" src="http://geekswithblogs.net/images/geekswithblogs_net/HouseOfBilz/WindowsLiveWriter/BindingtoResourcesinSilverlightWPF_C384/image_thumb_2.png" width="595" height="223" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Now my XAML should be able to bind to the resource, right?  Wrong: &lt;strong&gt;Unhandled Error in Silverlight 2 Application AG_E_PARSER_UNKNOWN_TYPE&lt;/strong&gt;.  This time, it is complaining because the constructor to this public class that Visual Studio generated is internal!  The class is public, but the constructor is internal, so the Silverlight/WPF engine still can't instantiate the object.&lt;/p&gt;

&lt;p&gt;I searched the interwebs, and I'm not alone with this problem.  Most people solve the problem by adding a custom build step that modifies the code.  Some even suggest changing the constructor to public by hand every time you update the resource table.  I am here to say: THERE IS A BETTER WAY!  I just created a public class with a single property that exposes the class:&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;public class i18nPublic
{
    private readonly static i18n resources = new i18n();
    public i18n Strings { get { return resources; } }
}&lt;/pre&gt;

&lt;p&gt;By adding this class, I can make a slight modification to the resource type and the binding path and I am now binding directly to the resources.&lt;/p&gt;

&lt;pre class="xml" name="code"&gt;&amp;lt;UserControl.Resources&amp;gt;
  &amp;lt;l:i18nPublic x:Key="i18n" /&amp;gt;
&amp;lt;/UserControl.Resources&amp;gt;

&amp;lt;StackPanel x:Name="LayoutRoot" Orientation="Horizontal"&amp;gt;
    &amp;lt;TextBox /&amp;gt;
    &amp;lt;Button Content="{Binding Path=Strings.SearchButton, Source={StaticResource i18n}}" /&amp;gt;
&amp;lt;/StackPanel&amp;gt;&lt;/pre&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130092"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=130092" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://houseofbilz.com/aggbug/130092.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Brian Genisio's House Of Bilz</dc:creator>
            <guid>http://houseofbilz.com/archive/2009/03/15/binding-to-resources-in-silverlightwpf.aspx</guid>
            <pubDate>Sun, 15 Mar 2009 14:15:08 GMT</pubDate>
            <wfw:comment>http://houseofbilz.com/comments/130092.aspx</wfw:comment>
            <comments>http://houseofbilz.com/archive/2009/03/15/binding-to-resources-in-silverlightwpf.aspx#feedback</comments>
            <slash:comments>7</slash:comments>
            <wfw:commentRss>http://houseofbilz.com/comments/commentRss/130092.aspx</wfw:commentRss>
            <trackback:ping>http://houseofbilz.com/services/trackbacks/130092.aspx</trackback:ping>
        </item>
        <item>
            <title>My Silverlight 3 Wish List</title>
            <link>http://houseofbilz.com/archive/2009/03/06/my-silverlight-3-wish-list.aspx</link>
            <description>&lt;a rev="vote-for" href="http://dotnetshoutout.com/My-Silverlight-3-Wish-List"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http%3A%2F%2Fwww.houseofbilz.com%2Farchive%2F2009%2F03%2F06%2Fmy-silverlight-3-wish-list.aspx" /&gt;&lt;/a&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fwww.houseofbilz.com%2farchive%2f2009%2f03%2f06%2fmy-silverlight-3-wish-list.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fwww.houseofbilz.com%2farchive%2f2009%2f03%2f06%2fmy-silverlight-3-wish-list.aspx" /&gt;&lt;/a&gt;   &lt;p&gt;I have been developing full time in Silverlight 2 for a few months now.  I must say, it is the most fun environment I have ever programmed in.  It has been an enabling technology in our product, and I am rather excited to see what comes next.  If the pattern continues as I expect it probably will, we will hear all about the features of Silverlight 3 in a few weeks at &lt;a href="http://visitmix.com/"&gt;Mix 09&lt;/a&gt;.  I will not be attending this conference, but I fully expect to be watching the important sessions virtually.  I am hoping for a lot.  You see, as much as I like the SIlverlight framework, it is missing some significant features that I can really use.&lt;/p&gt;  &lt;p&gt;So, I figured I would publish my Silverlight 3 wish list.  Some of these things are more important than others, but all of them are things that would make my "Rich Internet Application" more rich. &lt;strong&gt;I don't want this list to sound like I am just a big complainer.  &lt;/strong&gt;I think I am exercising the framework pretty hard, and Microsoft can only make the framework better with this list.  &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;MediaElement frame rate control: &lt;/strong&gt;The Silverlight media element is missing the ability to control the frame rate.  This keeps us from controlling the playback for slow-motion or fast-forward.  I have to imagine that the sports domain wants this as well.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;MediaElement loop control: &lt;/strong&gt;The current media element does not support looping of video content.  It can be programmed by hooking the "MediaEnded" event, putting the position at zero, and playing again, but this causes a noticeable pause.  This pause keeps looping play from being fluid.  It would be nice if the media element supported it directly.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Native video rendering: &lt;/strong&gt;Silverlight 2 does not use any hardware capabilities for video playback -- it is all done in software.  Therefore, the playback takes a lot of processor power.  This is really noticeable when four videos are playing simultaneously.  Any more on modern hardware is often choppy.  I would like to be able to play as many as nine videos at once.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;3D support: &lt;/strong&gt;Similar to the previous wish, Silverlight 2 does not use the video hardware directly.  This means that there is no 3D support.  It would be nice to see some 3D capabilities in Silverlight 3 -- preferably handled by hardware.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Direct bitmap manipulation: &lt;/strong&gt;Silverlight 2 does not support this, and there are certain types of effects and manipulations that are not possible in Silverlight.  I would love to see some bitmap manipulation capabilities&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Support for other data transports: &lt;/strong&gt;Currently, only HTTP requests are made available through the SIlverlight plug-in.  This limits the use of more sophisticated WCF bindings.  At a very minimum, it would be nice to be able to use TCP bindings via WCF.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Better mouse support: &lt;/strong&gt;Currently, we need to &lt;a href="http://www.houseofbilz.com/archive/2009/03/01/right-clicking-in-silverlight-2----a-refinement.aspx"&gt;hack in right-click&lt;/a&gt;, double-click and scroll-wheel capabilities.  It would be nice to have native support.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Support for drag-and-drop: &lt;/strong&gt;This is another case where I have &lt;a href="http://www.houseofbilz.com/archive/2009/02/10/drag-and-drop-with-silverlight.aspx"&gt;hacked something together&lt;/a&gt;, but it would be great if I were able to rely on the framework.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Native support for the MVVM pattern: &lt;/strong&gt;As far as I have figured, the MVVM pattern is the most suitable pattern for most large-scale Silverlight development.  It allows us to test the majority of our code and keep it out of the view.  Unfortunately, I haven't found MVVM to be well supported in the framework.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Commands -- They gave us ICommand, but nothing else.  I have hacked something in, but native support would be nice. &lt;/li&gt;    &lt;li&gt;See what &lt;a href="http://projects.nikhilk.net/SilverlightFX/"&gt;Silverlight.FX&lt;/a&gt; and &lt;a href="http://www.codeplex.com/caliburn"&gt;Cliburn&lt;/a&gt; have done.  Can we get something like this in the framework? &lt;/li&gt;    &lt;li&gt;Some sort of "Inversion of Control" or similar decoupling support?  Might MEF or Prism show up in SIlverlight 3? &lt;/li&gt;    &lt;li&gt;Stand-alone binding -- As far as I can tell, binding is only available in controls.  I can't write tests against controls.  I often want to bind data in my model to my view model.  I have written my own binder for this, but it would be nice to have some built-in support &lt;/li&gt;    &lt;li&gt;Better property notification.  INotifyPropertyChanged creates a lot of boiler-plate code in the view model.  I have minimized this by using a "property bag", but some utilities that make view models easier to write would be nice. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Interprocess communication: &lt;/strong&gt;I would like the ability to talk to other non-silverlight processes.  This seems like a tall order, but I have some business cases for this.&lt;/p&gt;  &lt;p&gt;That is all I have for now.  I am sure there is more that I am not thinking of.  I come across different needs every day.  For most cases, I have been able to hack some sort of support in when I need it.  In some cases, like the video playback support, I can't hack my wan out of the limitations.  &lt;/p&gt;  &lt;p&gt;This list looks like a lot now that I have written it down.  I am very curious to know if I will be getting any of these features.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129897"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129897" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://houseofbilz.com/aggbug/129897.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Brian Genisio's House Of Bilz</dc:creator>
            <guid>http://houseofbilz.com/archive/2009/03/06/my-silverlight-3-wish-list.aspx</guid>
            <pubDate>Sat, 07 Mar 2009 09:31:34 GMT</pubDate>
            <wfw:comment>http://houseofbilz.com/comments/129897.aspx</wfw:comment>
            <comments>http://houseofbilz.com/archive/2009/03/06/my-silverlight-3-wish-list.aspx#feedback</comments>
            <slash:comments>6</slash:comments>
            <wfw:commentRss>http://houseofbilz.com/comments/commentRss/129897.aspx</wfw:commentRss>
            <trackback:ping>http://houseofbilz.com/services/trackbacks/129897.aspx</trackback:ping>
        </item>
        <item>
            <title>Ann Arbor .NET Developers Group Has New Leadership!</title>
            <link>http://houseofbilz.com/archive/2009/02/12/ann-arbor-.net-developers-group-has-new-leadership.aspx</link>
            <description>&lt;p&gt;Last night, the &lt;a href="http://www.aadnd.org/"&gt;Ann Arbor .Net Developers&lt;/a&gt; group held annual elections, and made new director appointments.  The new leadership team is:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="FONT-WEIGHT: bold"&gt;President: &lt;/span&gt;&lt;a href="javascript:void(0);/*1234450632574*/"&gt;Jay Harris&lt;/a&gt;&lt;br /&gt;
&lt;span style="FONT-WEIGHT: bold"&gt;Vice President: &lt;/span&gt;&lt;a href="javascript:void(0);/*1234450693017*/"&gt;Scott Zischerk&lt;/a&gt;&lt;span style="FONT-WEIGHT: bold"&gt;&lt;br /&gt;
&lt;span style="FONT-WEIGHT: bold"&gt;Secretary: &lt;/span&gt;&lt;/span&gt;&lt;a href="javascript:void(0);/*1234450722209*/"&gt;Darrell Hawley&lt;/a&gt;&lt;br /&gt;
&lt;span style="FONT-WEIGHT: bold"&gt;Treasurer: &lt;/span&gt;Eric Bratton&lt;br /&gt;
&lt;br /&gt;
&lt;span style="FONT-WEIGHT: bold"&gt;Director of Programming: &lt;/span&gt;&lt;a href="javascript:void(0);/*1234450740770*/"&gt;Mike Woelmer&lt;/a&gt;&lt;br /&gt;
&lt;span style="FONT-WEIGHT: bold"&gt;Director of Membership: &lt;/span&gt;&lt;a href="javascript:void(0);/*1234450654547*/"&gt;Dennis Burton&lt;/a&gt;&lt;br /&gt;
&lt;span style="FONT-WEIGHT: bold"&gt;Director of Sponsorship: &lt;/span&gt;&lt;a href="javascript:void(0);/*1234450758584*/"&gt;Brian Genisio&lt;/a&gt; (me!)&lt;br /&gt;
&lt;br /&gt;
With my new role, I will be soliciting companies for sponsorship.  This will require me to get out there a bit more than I am used to, which is something that I have been pushing myself to do for about a year now.  I am excited to be a more significant part of the group, as this group means a lot to me.  I can't say that I know that I will be good in this role, but what the heck?  Lets give it a try.&lt;br /&gt;
&lt;br /&gt;
Now, who wants to give me some money? :)   &lt;span style="FONT-WEIGHT: bold"&gt; &lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129354"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129354" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://houseofbilz.com/aggbug/129354.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Brian Genisio's House Of Bilz</dc:creator>
            <guid>http://houseofbilz.com/archive/2009/02/12/ann-arbor-.net-developers-group-has-new-leadership.aspx</guid>
            <pubDate>Thu, 12 Feb 2009 22:02:24 GMT</pubDate>
            <wfw:comment>http://houseofbilz.com/comments/129354.aspx</wfw:comment>
            <comments>http://houseofbilz.com/archive/2009/02/12/ann-arbor-.net-developers-group-has-new-leadership.aspx#feedback</comments>
            <wfw:commentRss>http://houseofbilz.com/comments/commentRss/129354.aspx</wfw:commentRss>
            <trackback:ping>http://houseofbilz.com/services/trackbacks/129354.aspx</trackback:ping>
        </item>
        <item>
            <title>Drag and Drop with Silverlight</title>
            <link>http://houseofbilz.com/archive/2009/02/10/drag-and-drop-with-silverlight.aspx</link>
            <description>&lt;a href="http://dotnetshoutout.com/Drag-and-Drop-with-Silverlight" rev="vote-for"&gt;&lt;img style="border: 0px none ;" src="http://dotnetshoutout.com/image.axd?url=http%3A%2F%2Fhouseofbilz.com%2Farchive%2F2009%2F02%2F10%2Fdrag-and-drop-with-silverlight.aspx" alt="Shout it" /&gt;&lt;/a&gt; &lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fhouseofbilz.com%2farchive%2f2009%2f02%2f10%2fdrag-and-drop-with-silverlight.aspx"&gt;&lt;img border="0" alt="kick it on DotNetKicks.com" src="http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http%3a%2f%2fhouseofbilz.com%2farchive%2f2009%2f02%2f10%2fdrag-and-drop-with-silverlight.aspx" /&gt;&lt;/a&gt;
&lt;h3&gt;The Problem&lt;/h3&gt;
&lt;p&gt;I have been developing with Silverlight for a few months now, and I have really been enjoying myself.  It has been the enabling technology my project and we have been extremely productive in the environment.  Unfortunately, Silverlight is still in version 2.0 and there are some missing capabilities.&lt;/p&gt;
&lt;p&gt;One such hole in the framework is "Drag and Drop".  There is no support for it directly.  There are several blog examples on the web, but I have yet to find a fully encapsulated, generic solution to the "Drag and Drop" problem.  For instance, how soon after dragging do you really want to be dragging?  You don't want to drag immediately, as that will affect normal clicking on an element.  How do you handle drags from one distinct control to another that are not aware of each other?  How do you clue the user in that a given control is droppable?  How do you add animation to cue the user that the item is being dropped?&lt;/p&gt;
&lt;h3&gt;Introducing DragNDrop&lt;/h3&gt;
&lt;p&gt;To answer these questions, I created the &lt;strong&gt;DragNDrop&lt;/strong&gt; class.  It is a manager of sorts, and watches a "Drag Source" for the mouse down events.  The "Drag Source" implements an interface and the "Drop Spot" implements a complimentary interface.  This allows for the "Drag Source" and "Drop Spot" to be blissfully unaware of each other.&lt;/p&gt;
&lt;h3&gt;Usage&lt;/h3&gt;
&lt;p&gt;The assumption made with this class is that there is some sort of a payload.  This payload is picked up from the "Drag Source" and dropped into the "Drop Spot".  The "Drop Spot" can accept a payload of any types that it implements from any "Drag Source" that implements the complementary interface.  Lets take a look at the interfaces:&lt;/p&gt;
&lt;pre class="c-sharp" name="code"&gt;public class DragNDrop&amp;lt;PayloadType&amp;gt;
{
    public interface IThumbnailDragSource
    {
        FrameworkElement DragCursor { get; }
        PayloadType Payload { get; }
    }
    
    public interface IThumbnailDropSpot
    {
        void DragDropEnter();
        void DragDropExit();  
        void ThumbnailDroping(PayloadType dataContext, FrameworkElement cursor, Point cursorPosition);
    }
}&lt;/pre&gt;
&lt;p&gt;For instance, if a "Drag Source" wanted to allow dragging with a string payload, it would implement &lt;strong&gt;DragNDrop&amp;lt;string&amp;gt;.IThumbnailDragSource&lt;/strong&gt;.  Any "Drop Spot" that wants to accept a string payload would implement &lt;strong&gt;DragNDrop&amp;lt;string&amp;gt;.IThumbnailDropSpot&lt;/strong&gt;.  The &lt;strong&gt;DragNDrop&lt;/strong&gt; class is then constructed with an instance of the "Drag Source" and the &lt;strong&gt;DragNDrop&lt;/strong&gt; class handles everything else.&lt;/p&gt;
&lt;p&gt;In addition to the payload, the "Drag Source" needs to provide the &lt;strong&gt;DragNDrop&lt;/strong&gt; class with the cursor that will be displayed and dragged across the screen.  This can be anything; an image, a user control, a rectangle, etc.&lt;/p&gt;
&lt;p&gt;The "Drop Spot" will be notified when the cursor is entering and exiting its space, so it can react appropriately.  It will also be notified when the payload is dropped with the instance of the cursor and the absolute position.  This is necessary in case the "Drop Spot" wants to animate the drop in any way.&lt;/p&gt;
&lt;h3&gt;The Demo&lt;/h3&gt;
&lt;p&gt;I created the &lt;a href="http://brianstestsite.googlepages.com/DragAndDrop.html"&gt;Twitter Search Tool&lt;/a&gt; to prove out this concept.  The idea is that search for a term and it returns a list of tweets. When you find a tweet that you like, you can drop it on to the second list to keep track of it.  It is not the most functional app in the world, but it illustrates the usage of the &lt;strong&gt;DragNDrop&lt;/strong&gt; class nicely.  Take a moment to try it out.&lt;/p&gt;
&lt;p&gt;Now that you have seen it in action, lets take a look at how I use the &lt;strong&gt;DragNDrop&lt;/strong&gt; class.  This application uses a small data structure called &lt;strong&gt;Tweet&lt;/strong&gt;.  It contains all of the information about a given tweet (user name, user image, text, etc).  The &lt;strong&gt;Tweet&lt;/strong&gt; is the payload.&lt;/p&gt;
&lt;p&gt;In the Silverlight UI, I created a user control to represent each item in the list called &lt;strong&gt;ListItem&lt;/strong&gt;.  The XAML is available in the full source if you are curious.&lt;/p&gt;
&lt;pre class="c-sharp" name="code"&gt;public partial class ListItem : UserControl, DragNDrop&amp;lt;Tweet&amp;gt;.IThumbnailDragSource
{
    private readonly DragNDrop&amp;lt;Tweet&amp;gt; _dragNDrop;

    public ListItem()
    {
        InitializeComponent();

        _dragNDrop = new DragNDrop&amp;lt;Tweet&amp;gt;(this);
        _dragNDrop.DraggingEnabledDistance = 5.0;
    }

    public FrameworkElement DragCursor
    {
        get
        {
            return new Image
            {
                Width = TweetImage.ActualWidth,
                Height = TweetImage.ActualHeight,
                Source = TweetImage.Source,
                Opacity = 0.5
            };
        }
    }

    public Tweet Payload
    {
        get { return DataContext as Tweet; }
    }
}&lt;/pre&gt;
&lt;p&gt;This code is pretty straight-forward.  The DragCursor returns a new image with the picture of the user.  The payload is the actual Tweet.  The constructor creates an instance of &lt;strong&gt;DragNDrop&lt;/strong&gt; and passes itself in as the source.  It also sets the &lt;strong&gt;DraggingEnabledDistance&lt;/strong&gt;.  This is the distance (in pixels) that the user must drag before the dragging really begins.  The default is 10 pixels.&lt;/p&gt;
&lt;p&gt;Next, lets take a look at the "Drop Spot" code.  It is also a user control, &lt;strong&gt;TweetDropList,&lt;/strong&gt; which includes a ListBox control.  It also includes an opaque canvas that gives the effect of highlighting when it is made visible.&lt;/p&gt;
&lt;pre class="c-sharp" name="code"&gt;public partial class TweetDropList : DragNDrop&amp;lt;Tweet&amp;gt;.IThumbnailDropSpot
{
    private readonly ObservableCollection&amp;lt;Tweet&amp;gt; _savedTweets = new ObservableCollection&amp;lt;Tweet&amp;gt;();

    public TweetDropList()
    {
        InitializeComponent();
        DropList.ItemsSource = _savedTweets;
    }

    public void DragDropEnter()
    {
        Highlight.Visibility = Visibility.Visible;
    }

    public void DragDropExit()
    {
        Highlight.Visibility = Visibility.Collapsed;
    }

    public void ThumbnailDroping(Tweet dataContext, FrameworkElement cursor, Point cursorPosition)
    {
        DragDropExit();
        AnimateCursor(cursor, cursorPosition, () =&amp;gt; _savedTweets.Add(dataContext));
    }
}&lt;/pre&gt;
&lt;p&gt;I have left out the &lt;strong&gt;AnimateCursor&lt;/strong&gt; code, but it simply generates a storyboard on the cursor and quickly morphs it down to a size of zero.  That code can be found in the source bundle.  The rest of this implementation is extremely simple.  &lt;strong&gt;DragDropEnter&lt;/strong&gt; and &lt;strong&gt;DragDropExit&lt;/strong&gt; simply hides and shows the highlight layer.  &lt;strong&gt;ThumbnailDropping&lt;/strong&gt; will remove the highlighting layer and animate the cursor to give the effect of the item being dropped.  When the animation completes, the new tweet is added to the &lt;strong&gt;_savedTweets&lt;/strong&gt; collection, which will cause the&lt;strong&gt; &lt;/strong&gt;user control to display the new tweet.&lt;/p&gt;
&lt;h3&gt;Thats It!&lt;/h3&gt;
&lt;p&gt;I designed the &lt;strong&gt;DragNDrop&lt;/strong&gt; class to be as simple to use as possible.  I have been using a version of this class in my product and I have had great results.  The "Drop Spots" can implement as many versions of &lt;strong&gt;IThumbnailDropSpot&lt;/strong&gt; as it needs to allow different types of items to be dragged.  The &lt;strong&gt;DragNDrop&lt;/strong&gt; class can be instantiated as many times as necessary, for every "Drag Source".  &lt;/p&gt;
&lt;p&gt;Please play with this class and give me feedback.  I'd love to hear how it is being used.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://brianstestsite.googlepages.com/DragAndDrop.html"&gt;DragNDrop Twitter Demo&lt;/a&gt;     &lt;br /&gt;
&lt;a href="http://brianstestsite.googlepages.com/DragNDrop_Source.zip"&gt;DragNDrop Twitter Demo Source&lt;/a&gt;     &lt;br /&gt;
&lt;a href="http://brianstestsite.googlepages.com/DragNDrop.cs"&gt;DragNDrop.cs&lt;/a&gt;     &lt;br /&gt;
&lt;a href="http://brianstestsite.googlepages.com/Extensisons.cs"&gt;Extensions.cs&lt;/a&gt; (a handful of extension methods that DragNDrop uses)&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129320"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=129320" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://houseofbilz.com/aggbug/129320.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Brian Genisio's House Of Bilz</dc:creator>
            <guid>http://houseofbilz.com/archive/2009/02/10/drag-and-drop-with-silverlight.aspx</guid>
            <pubDate>Wed, 11 Feb 2009 09:49:06 GMT</pubDate>
            <wfw:comment>http://houseofbilz.com/comments/129320.aspx</wfw:comment>
            <comments>http://houseofbilz.com/archive/2009/02/10/drag-and-drop-with-silverlight.aspx#feedback</comments>
            <slash:comments>4</slash:comments>
            <wfw:commentRss>http://houseofbilz.com/comments/commentRss/129320.aspx</wfw:commentRss>
            <trackback:ping>http://houseofbilz.com/services/trackbacks/129320.aspx</trackback:ping>
        </item>
        <item>
            <title>Testing WCF Service Apps (part 4 of 4)</title>
            <link>http://houseofbilz.com/archive/2009/01/05/testing-wcf-service-apps-part-4-of-4.aspx</link>
            <description>&lt;p&gt;Previous Posts:    &lt;br /&gt;&lt;a href="http://houseofbilz.com/HouseOfBilz/archive/2008/11/18/testing-wcf-service-apps-part-0-of-4.aspx"&gt;Part 0 of 4: Introduction&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://houseofbilz.com/archive/2008/11/24/testing-wcf-service-apps-part-1-of-4.aspx"&gt;Part 1 of 4: Testing the Service&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://www.houseofbilz.com/archive/2008/11/29/testing-wcf-service-apps-part-2-of-4.aspx"&gt;Part 2 of 4: Testing the Client&lt;/a&gt;     &lt;br /&gt;&lt;a href="http://www.houseofbilz.com/archive/2008/12/19/testing-wcf-service-apps-part-3-of-4.aspx"&gt;Part 3 of 4: Testing the Asynchronous Client&lt;/a&gt; &lt;/p&gt; &lt;a rev="vote-for" href="http://dotnetshoutout.com/Testing-WCF-Services"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" alt="Shout it" src="http://dotnetshoutout.com/image.axd?url=http%3A%2F%2Fhouseofbilz.com%2FHouseOfBilz%2Farchive%2F2008%2F11%2F18%2Ftesting-wcf-service-apps-part-0-of-4.aspx" /&gt;&lt;/a&gt;   &lt;h3&gt;Functional Testing the WCF Application&lt;/h3&gt;  &lt;p&gt;In functional testing, the goal is to test as much of the application that you can to determine that it does what you want from a functional perspective.  It differs greatly from unit testing in that a unit test is only concerned with an individual class.  Functional tests are concerned with testing the interactions of the objects in the system from the user input to the user output.&lt;/p&gt;  &lt;p&gt;I thought it would be easiest to draw out what the data mining application is doing in terms of data flow.  This particular application is a data mining application which queries a service to pull out data that the user wants.  In this case, the question that the user wants answered is "What recipes exist in the database that include a given ingredient?"  The data flow goes like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/HouseOfBilz/WindowsLiveWriter/a0b52042f47e_BD87/App.Diagram_2.png"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="App.Diagram" src="http://geekswithblogs.net/images/geekswithblogs_net/HouseOfBilz/WindowsLiveWriter/a0b52042f47e_BD87/App.Diagram_thumb.png" width="613" height="410" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The user types an ingredient into the console.  The console launches our application and calls "&lt;strong&gt;Main&lt;/strong&gt;" with the arguments that include the ingredient in question.  The "&lt;strong&gt;Main&lt;/strong&gt;" routine creates an &lt;strong&gt;IngredientFinder&lt;/strong&gt; object which requests a list of all recipes known to the service.  It does this by asking the service proxy which uses WCF to ask the actual &lt;strong&gt;RecipeService&lt;/strong&gt;, which may exist anywhere on the planet.  The actual &lt;strong&gt;RecipeService&lt;/strong&gt; asks the &lt;strong&gt;Business Objects&lt;/strong&gt; which in turn queries the database for all known recipes.  The database returns the results to the &lt;strong&gt;Business Objects&lt;/strong&gt; which in turn returns the results to the &lt;strong&gt;RecipeService&lt;/strong&gt;.  Those results travel through the WCF infrastructure back to the service proxy in the client.  The &lt;strong&gt;IngredientFinder&lt;/strong&gt; filters the recipes for the requested ingredient and returns the results to the "&lt;strong&gt;Main&lt;/strong&gt;" method which then writes the results back to the console for the user to read.&lt;/p&gt;  &lt;p&gt;From a testing perspective, the only code we are responsible for in this system is &lt;strong&gt;Main, IngredientFinder, RecipeService&lt;/strong&gt; and &lt;strong&gt;Business Objects&lt;/strong&gt;.  The user and console are completely external to our application.  The service proxy is auto-generated by Visual Studio and the WCF framework is part of the .NET framework.  We do not need to test these parts.  Finally, the database is also a Microsoft product (SQL Server) and we can trust that it works correctly as well.  We need to eliminate all components in this system that we do not control, thus focus on testing the code in which we do control.&lt;/p&gt;  &lt;h3&gt;Eliminating the User and Console&lt;/h3&gt;  &lt;p&gt;Traditionally our "&lt;strong&gt;Main&lt;/strong&gt;" method would instantiate our IngredientFinder (see part 1) with the service proxy, get the result and write it out to the console:&lt;/p&gt;  &lt;pre class="c-sharp" name="code"&gt;static void Main(string[] args)
{
    var finder = new IngredientFinder(new RecipeBoxServiceClient());

    foreach (RecipeData recipe in finder.GetRecipes(args[0]))
        Console.WriteLine(recipe.Title);

    Console.ReadKey();
}&lt;/pre&gt;

&lt;p&gt;The problem with this is that &lt;strong&gt;Console&lt;/strong&gt; is a static class and cannot be replaced as-is.  Instead, we need to extract this as an interface and pass the interface in:&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;public interface IConsoleOutput
{
    void WriteLine(string line);
    ConsoleKeyInfo ReadKey();
}

private class ConsoleOutput : IConsoleOutput
{
    public void WriteLine(string line) { Console.WriteLine(line); }
    public ConsoleKeyInfo ReadKey() { return Console.ReadKey(); }
}&lt;/pre&gt;

&lt;p&gt;By doing this, we can now replace the &lt;strong&gt;Console.WriteLine&lt;/strong&gt; static method with a spy in our test (later).  We will create a new static method named &lt;strong&gt;Execute&lt;/strong&gt; which passes in the &lt;strong&gt;IConsoleOutput&lt;/strong&gt; and &lt;strong&gt;IRecipeBoxService&lt;/strong&gt; interfaces. Our new "&lt;strong&gt;Main&lt;/strong&gt;" routine will look like this:&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;static void Main(string[] args)
{
    Execute(new ConsoleOutput(), new RecipeBoxServiceClient(), args);
}

public static void Execute(IConsoleOutput console, IRecipeBoxService service, string[] args)
{
    var finder = new IngredientFinder(service);

    foreach (RecipeData recipe in finder.GetRecipes(args[0]))
        console.WriteLine(recipe.Title);

    console.ReadKey();
}&lt;/pre&gt;

&lt;h3&gt;Eliminating the WCF Infrastructure&lt;/h3&gt;

&lt;p&gt;Now that the user and console have been abstracted out, we can start thinking about testing the &lt;strong&gt;Execute&lt;/strong&gt; method.  The problem we have now is that &lt;strong&gt;IRecipeBoxService&lt;/strong&gt; is an automatically generated interface within the client's namespace.  We have an implementation of this interface in the service, but it is defined in the service's namespace.  The two interfaces are not compatible.  We want to eliminate the need for WCF, so we cannot use the generated proxy class.  What we need here is a bridge class:&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;public class ServiceWrapper : DataMining.RecipeBoxService.IRecipeBoxService
{
    private readonly Services.IRecipeBoxService _source;

    public ServiceWrapper(Services.IRecipeBoxService source)
    {
        _source = source;
    }

    private static ToType TranslateData&amp;lt;FromType, ToType&amp;gt;(FromType source) where ToType : class
    {
        var serverSerializer = new DataContractSerializer(typeof(FromType));
        var clientSerializer = new DataContractSerializer(typeof(ToType));

        using (var stream = new MemoryStream())
        {
            serverSerializer.WriteObject(stream, source);
            stream.Flush();
            stream.Position = 0;

            return clientSerializer.ReadObject(stream) as ToType;
        }
    }

    public DataMining.RecipeBoxService.RecipeData[] AllRecipes()
    {
        var result = new List&amp;lt;DataMining.RecipeBoxService.RecipeData&amp;gt;();
        foreach (var data in _source.AllRecipes())
            result.Add(TranslateData&amp;lt;Services.DataContracts.RecipeData, DataMining.RecipeBoxService.RecipeData&amp;gt;(data));
        return result.ToArray();
    }

    ...
}&lt;/pre&gt;

&lt;p&gt;This class bridges the client interface over to the service interface.  WCF interfaces are made up of Service Contracts and Data Contracts.  The Service Contract is the functional interface where the Data Contract defines what the data looks like.  The WCF framework uses the &lt;strong&gt;System.Runtime.Serialization.DataContractSerializer&lt;/strong&gt; to transfer the data in plain-text.  In this &lt;strong&gt;ServiceWrapper&lt;/strong&gt; class, the &lt;strong&gt;TranslateData&lt;/strong&gt; function uses the &lt;strong&gt;DataContractSerializer&lt;/strong&gt; to serialize the data to and from the client and service data types.  This class is the glue that replaces WCF from the testing process.  In a sense, this class is a very simple implementation of the WCF concepts.&lt;/p&gt;

&lt;h3&gt;Putting it all Together&lt;/h3&gt;

&lt;p&gt;The only piece of functionality still out of our control is the database.  I am going to replace the SQL Server with a temporal, in-memory database for testing.  This post will not go into the details, but my previous post on Blah Blah Blah talks about how to do this.  Now, our diagram looks shows a system where every piece of code is in our control:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://geekswithblogs.net/images/geekswithblogs_net/HouseOfBilz/WindowsLiveWriter/a0b52042f47e_BD87/App.Testing_2.png"&gt;&lt;img style="border-right-width: 0px; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" border="0" alt="App.Testing" src="http://geekswithblogs.net/images/geekswithblogs_net/HouseOfBilz/WindowsLiveWriter/a0b52042f47e_BD87/App.Testing_thumb.png" width="636" height="302" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h3&gt;&lt;strong&gt;Writing our Functional Tests&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;The only code we still need before we start writing functional tests is the &lt;strong&gt;ConsoleOutputSpy&lt;/strong&gt;.  It captures the output in a list of strings that we can verify against.&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;public class ConsoleOutputSpy : Program.IConsoleOutput
{
    public List&amp;lt;string&amp;gt; Output { get; private set; }
    
    public ConsoleOutputSpy()          { Output = new List&amp;lt;string&amp;gt;(); }
    public void WriteLine(string line) { Output.Add(line); }
    public ConsoleKeyInfo ReadKey()    { return new ConsoleKeyInfo(); }
}&lt;/pre&gt;

&lt;p&gt;Now that we have our console output spy, we can look at our test &lt;strong&gt;SetUp&lt;/strong&gt;:&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;private ConsoleOutputSpy _consoleOutput;
private DataMining.RecipeBoxService.IRecipeBoxService _service;

[SetUp]
public void SetUp()
{
    _service = new ServiceWrapper(new RecipeBoxService(new MockBackEndConfiguration()));
    _consoleOutput = new ConsoleOutputSpy();
}&lt;/pre&gt;

&lt;p&gt;Finally, we can write our tests.  This test will populate the mock database with four ingredients and three recipes.  Only two of the recipes include the "Cheese" ingredient, so we can test that our data miner will return only those two recipes that contain "Cheese":&lt;/p&gt;

&lt;pre class="c-sharp" name="code"&gt;[Test]
public void SimpleTest()
{
    AddIngredients("Macaroni", "Cheese", "Bread", "Peanut Butter");
    AddRecipeToDatabase("Mac &amp;amp; Cheese", "Macaroni", "Cheese");
    AddRecipeToDatabase("Grilled Cheese", "Bread", "Cheese");
    AddRecipeToDatabase("Peanut Butter Sandwich", "Bread", "Peanut Butter");

    Program.Execute(_consoleOutput, _service, new [] {"Cheese"});

    Assert.That(_consoleOutput.Output.Count, Is.EqualTo(2));
    Assert.That(_consoleOutput.Output[0], Is.EqualTo("Mac &amp;amp; Cheese"));
    Assert.That(_consoleOutput.Output[1], Is.EqualTo("Grilled Cheese"));
}&lt;/pre&gt;

&lt;h3&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/h3&gt;

&lt;p&gt;This concludes my four-part series on testing WCF applications.  I have covered unit testing the service, unit testing the client, unit testing an asynchronous client and finally, functional testing the entire application.  &lt;/p&gt;

&lt;p&gt;It is important for me to note that these techniques have served me very well in the real-world.  I have a Silverlight application which communicates asynchronously with a back-end WCF service.  These techniques have allowed us to write tests that cover our application from all aspects.  The tests we have in place run extremely quickly and are robust because they do not rely on any services running on a separate machine.&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128384"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=128384" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://houseofbilz.com/aggbug/128384.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Brian Genisio's House Of Bilz</dc:creator>
            <guid>http://houseofbilz.com/archive/2009/01/05/testing-wcf-service-apps-part-4-of-4.aspx</guid>
            <pubDate>Tue, 06 Jan 2009 09:56:25 GMT</pubDate>
            <wfw:comment>http://houseofbilz.com/comments/128384.aspx</wfw:comment>
            <comments>http://houseofbilz.com/archive/2009/01/05/testing-wcf-service-apps-part-4-of-4.aspx#feedback</comments>
            <slash:comments>6</slash:comments>
            <wfw:commentRss>http://houseofbilz.com/comments/commentRss/128384.aspx</wfw:commentRss>
            <trackback:ping>http://houseofbilz.com/services/trackbacks/128384.aspx</trackback:ping>
        </item>
    </channel>
</rss>