<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://msmvps.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Search results for 'app:weblogs' matching tag 'Agile'</title><link>http://msmvps.com/search/SearchResults.aspx?q=app:weblogs&amp;tag=Agile&amp;orTags=0&amp;o=DateDescending</link><description>Search results for 'app:weblogs' matching tag 'Agile'</description><dc:language>en-US</dc:language><generator>CommunityServer 2008.5 SP2 (Build: 40407.4157)</generator><item><title>Mscorlib mocking minus the attribute</title><link>http://msmvps.com/blogs/mehfuz/archive/2012/07/09/mscorlib-mocking-minus-the-attribute.aspx</link><pubDate>Mon, 09 Jul 2012 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1812596</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;Mocking .net framework members (a.k.a. mscorlib) is always a daunting task. It’s the breed of static and final methods and full of surprises. Technically intercepting mscorlib members is completely different from other class libraries. This is the reason it is dealt differently. Generally, I prefer writing a wrapper around an mscorlib member (Ex. File.Delete(“abc.txt”)) and expose it via interface but that is not always an easy task if you already have years old codebase.&lt;/p&gt;  &lt;p&gt;While mocking mscorlib members first thing that comes to people’s mind is &lt;em&gt;DateTime.Now&lt;/em&gt;. If you Google through, you will find tons of example dealing with just that. May be it’s the most important class that we can’t ignore and I will create an example using JustMock Q2 with the same.&lt;/p&gt;  &lt;p&gt;In Q2 2012, we just get rid of the &lt;i&gt;MockClassAtrribute&lt;/i&gt; for mocking mscorlib members. JustMock is already &lt;i&gt;attribute&lt;/i&gt; free for mocking class libraries. We radically think that vendor specific attributes only makes your code smelly and therefore decided the same for mscorlib.&lt;/p&gt;  &lt;p&gt;Now, I want to fake &lt;i&gt;DateTime.Now &lt;/i&gt;for the following class:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; NestedDateTime
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; DateTime GetDateTime()
    {
        &lt;span class="kwrd"&gt;return&lt;/span&gt; DateTime.Now;
    }
}&lt;/pre&gt;

&lt;p&gt;It is the simplest one that can be. The first thing here is that I tell JustMock “hey we have a&lt;em&gt; DateTime.Now&lt;/em&gt; in &lt;em&gt;NestedDateTime&lt;/em&gt; class that we want to mock”.&lt;/p&gt;

&lt;p&gt;To do so, during the test initialization I write this:&lt;/p&gt;


&lt;p&gt;&lt;/p&gt;

&lt;pre class="csharpcode"&gt;Mock.Replace(() =&amp;gt; DateTime.Now).In&amp;lt;NestedDateTime&amp;gt;(x =&amp;gt; x.GetDateTime());&lt;/pre&gt;

&lt;p&gt;I can also define it for all the members in the class, but that’s just a waste of extra watts.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;Mock.Replace(() =&amp;gt; DateTime.Now).In&amp;lt;NestedDateTime&amp;gt;();&lt;/pre&gt;

&lt;p&gt;Now question, why should I bother doing it? The answer is that I am not using attribute and with this approach, I can mock any framework members not just &lt;i&gt;File&lt;/i&gt;, &lt;i&gt;FileInfo&lt;/i&gt; or &lt;i&gt;DateTime&lt;/i&gt;. Here to note that we already mock beyond the three but when nested around a complex class, JustMock was not intercepting it correctly. Therefore, we decided to get rid of the attribute altogether fixing the issue.&lt;/p&gt;

&lt;p&gt;Finally, I write my test as usual.&lt;/p&gt;

&lt;pre class="csharpcode"&gt;[TestMethod]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ShouldAssertMockingDateTimeFromNestedClass()
{
    var expected = &lt;span class="kwrd"&gt;new&lt;/span&gt; DateTime(2000, 1, 1);

    Mock.Arrange(() =&amp;gt; DateTime.Now).Returns(expected);

    Assert.Equal(&lt;span class="kwrd"&gt;new&lt;/span&gt; NestedDateTime().GetDateTime(), expected);
}&lt;/pre&gt;


&lt;p&gt;That’s it, we are good. Now let me do the same for a random one, let’s say I want mock a member from &lt;em&gt;DriveInfo&lt;/em&gt;:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;Mock.Replace&amp;lt;DriveInfo[]&amp;gt;(() =&amp;gt; DriveInfo.GetDrives()).In&amp;lt;MsCorlibFixture&amp;gt;(x =&amp;gt; x.ShouldReturnExpectedDriveWhenMocked());&lt;/pre&gt;

&lt;p&gt;Moving forward, I write my test:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;[TestMethod]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ShouldReturnExpectedDriveWhenMocked()
{
    Mock.Arrange(() =&amp;gt; DriveInfo.GetDrives()).MustBeCalled();

    DriveInfo.GetDrives();

    Mock.Assert(()=&amp;gt; DriveInfo.GetDrives());
}&lt;/pre&gt;


&lt;p&gt;Here is one convention; you have to replace the mscorlib member before executing the target method that contains it. Here the call to &lt;i&gt;DriveInfo&lt;/i&gt; is within the MsCorlibFixture therefore it should be defined during test initialization or before executing the test method.&lt;/p&gt;

&lt;p&gt;&lt;font size="2" face="Consolas"&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;Hope this gives you the idea.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=8716170" width="1" height="1" alt="" /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=xoM6w3Gmgcw:OjTYTn5-fKk:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?d=yIl2AUoC8zA" border="0" alt="" /&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=xoM6w3Gmgcw:OjTYTn5-fKk:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?d=qj6IDK7rITs" border="0" alt="" /&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=xoM6w3Gmgcw:OjTYTn5-fKk:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?d=7Q72WNTAKBA" border="0" alt="" /&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=xoM6w3Gmgcw:OjTYTn5-fKk:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?i=xoM6w3Gmgcw:OjTYTn5-fKk:F7zBnMyn0Lo" border="0" alt="" /&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/burncsharp/~4/xoM6w3Gmgcw" height="1" width="1" alt="" /&gt;</description></item><item><title>Fake a member without worrying about passing the dependency</title><link>http://msmvps.com/blogs/mehfuz/archive/2011/07/21/fake-a-member-without-worrying-about-passing-the-dependency.aspx</link><pubDate>Thu, 21 Jul 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1796527</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;I have came across this several times in forum (telerik) on how I can really fake an item yet I don’t want to pass the instance as an argument. Ideally, this is not a best design but there are third- partly libraries that you have little control over how its written.&amp;#160; Anyway, whatever the case might be. This post will show you how you can achieve the above using JustMock. I will be using MSpec in conjunction for the example.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;So here is the sample class that I am going to use:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:6464b8e6-09bc-493f-8db9-97e961ea1391" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background:#ddd;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#000000;margin:0 0 0 2em;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#d7d7c8;"&gt;&lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;public&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;class&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#efefaf;"&gt;LegacyCode&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;&lt;span style="color:#d7d7c8;"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#d7d7c8;"&gt;&lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;public&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;int&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; CheckUser(&lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;string&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; userName, &lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;string&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; password)&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#d7d7c8;"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#d7d7c8;"&gt;&lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;var&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; _service = &lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;new&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#efefaf;"&gt;LoginService&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt;();&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;        &lt;span style="color:#d7d7c8;"&gt;&lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;return&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; _service.ValidateUser(userName, password);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#d7d7c8;"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;&lt;span style="color:#d7d7c8;"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Here &lt;em&gt;CheckUser&lt;/em&gt; is calling&amp;#160; &lt;em&gt;LoginService.ValidateUser&lt;/em&gt; that we are going replace with a fake call. Also here is the&amp;#160; &lt;em&gt;LoginService &lt;/em&gt;class&lt;em&gt; &lt;/em&gt;that is not much significant just throws exception when &lt;em&gt;ValidateUser&lt;/em&gt; is called that will even confirm if the correct variant is invoked.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:fd4cc166-da3d-42b6-94b8-da7148bc3f59" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background:#ddd;overflow:auto;"&gt; &lt;ol style="background:#000000;margin:0 0 0 2em;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#d7d7c8;"&gt;&lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;public&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;class&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#efefaf;"&gt;LoginService&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#d7d7c8;"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#d7d7c8;"&gt;&lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;public&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;int&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; ValidateUser(&lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;string&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; userName, &lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;string&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; password)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#d7d7c8;"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#d7d7c8;"&gt;&lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;throw&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;new&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#00008b;"&gt;NotImplementedException&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt;(&lt;/span&gt;&lt;span style="color:#dca3a3;"&gt;&amp;quot;Nothing here&amp;quot;&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt;);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#d7d7c8;"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#d7d7c8;"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Here is the specification that I wrote with Justmock and MSpec&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:95e21847-27a2-4305-bfa9-990e48775662" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background:#ddd;overflow:auto;"&gt; &lt;ol style="background:#000000;margin:0 0 0 2.5em;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#d7d7c8;"&gt;[&lt;/span&gt;&lt;span style="color:#efefaf;"&gt;Subject&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt;(&lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;typeof&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt;(&lt;/span&gt;&lt;span style="color:#efefaf;"&gt;LoginService&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt;))]&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;  &lt;span style="color:#d7d7c8;"&gt;&lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;public&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;class&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#efefaf;"&gt;when_a_mock_is_called_without_instance_being_injected&lt;/span&gt;&lt;/li&gt; &lt;li&gt;  &lt;span style="color:#d7d7c8;"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;      &lt;span style="color:#d7d7c8;"&gt;&lt;/span&gt;&lt;span style="color:#efefaf;"&gt;Establish&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; context = () =&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;      &lt;span style="color:#d7d7c8;"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;          &lt;span style="color:#d7d7c8;"&gt;service = &lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;new&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#efefaf;"&gt;LoginService&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt;();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;          &lt;span style="color:#d7d7c8;"&gt;&lt;/span&gt;&lt;span style="color:#efefaf;"&gt;Mock&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt;.Arrange(() =&amp;gt; service.ValidateUser(userName, password)).MustBeCalled();&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;      &lt;span style="color:#d7d7c8;"&gt;};&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li class="even"&gt;      &lt;span style="color:#d7d7c8;"&gt;&lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;private&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#efefaf;"&gt;Because&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; of = () =&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;      &lt;span style="color:#d7d7c8;"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;          &lt;span style="color:#d7d7c8;"&gt;&lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;var&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; sut = &lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;new&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#efefaf;"&gt;LegacyCode&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt;();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;          &lt;span style="color:#d7d7c8;"&gt;sut.CheckUser(userName, password);&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;      &lt;span style="color:#d7d7c8;"&gt;};&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li class="even"&gt;      &lt;span style="color:#d7d7c8;"&gt;&lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;private&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#efefaf;"&gt;It&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; must_assert_that_fake_setup_is_invoked_from_context = () =&amp;gt; &lt;/span&gt;&lt;/li&gt; &lt;li&gt;          &lt;span style="color:#d7d7c8;"&gt;&lt;/span&gt;&lt;span style="color:#efefaf;"&gt;Mock&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt;.Assert(service);&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li class="even"&gt;      &lt;span style="color:#d7d7c8;"&gt;&lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;static&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#efefaf;"&gt;LoginService&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; service;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;      &lt;span style="color:#d7d7c8;"&gt;&lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;readonly&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;static&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;string&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; userName = &lt;/span&gt;&lt;span style="color:#dca3a3;"&gt;&amp;quot;User&amp;quot;&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt;;&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;      &lt;span style="color:#d7d7c8;"&gt;&lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;readonly&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;static&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; &lt;/span&gt;&lt;span style="color:#dac6a5;"&gt;string&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt; password = &lt;/span&gt;&lt;span style="color:#dca3a3;"&gt;&amp;quot;Pwd&amp;quot;&lt;/span&gt;&lt;span style="color:#d7d7c8;"&gt;;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;  &lt;span style="color:#d7d7c8;"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;This concludes that if you have a mock setup and you cant pass the instance via dependency injection, JustMock will still try to find the closest mock setup for arguments that it will replace the original call with when invoked. There is no extra setup call to be associated in that regard and keeps the tool more out of your way. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In addition I am attaching the sample project to let you have a look. Also you will be needing JustMock full edition installed to try this out.&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:F60BB8FA-6F02-4999-8F5E-9DD4E92C4DA7:78332689-7051-4989-8cca-eb156a6d44d7" class="wlWriterEditableSmartContent"&gt;&lt;div&gt;&lt;a href="http://weblogs.asp.net/blogs/mehfuzh/JustMock_Legacy01_5FB2271C.zip" target="_blank"&gt;JustMock_Legacy01.zip&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7878112" width="1" height="1" alt="" /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=BQAaNyBoxio:9WBxqpNQT8M:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?d=yIl2AUoC8zA" border="0" alt="" /&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=BQAaNyBoxio:9WBxqpNQT8M:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?d=qj6IDK7rITs" border="0" alt="" /&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=BQAaNyBoxio:9WBxqpNQT8M:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?d=7Q72WNTAKBA" border="0" alt="" /&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=BQAaNyBoxio:9WBxqpNQT8M:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?i=BQAaNyBoxio:9WBxqpNQT8M:F7zBnMyn0Lo" border="0" alt="" /&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/burncsharp/~4/BQAaNyBoxio" height="1" width="1" alt="" /&gt;</description></item><item><title>Problems and workaround for the EMC Scrum for Team System Process Template</title><link>http://msmvps.com/blogs/rfennell/archive/2011/05/04/problems-and-workaround-for-the-emc-scrum-for-team-system-process-template.aspx</link><pubDate>Wed, 04 May 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1792691</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;I have recently been looking at the &lt;a href="http://www.scrumforteamsystem.com/"&gt;EMC Scrum for Team Systems (SFTS) 3 Template for TFS 2010&lt;/a&gt; with SharePoint 2010. The core of it works, and works well for Scrum based teams. If you have not used it before have a read of the &lt;a href="http://consultingblogs.emc.com/crispinparker/archive/2010/05/18/getting-started-with-scrum-for-team-system-version-3-tfs-2010.aspx"&gt;getting started post&lt;/a&gt; to get a feel of what it can do.&lt;/p&gt;  &lt;p&gt;However, there are some issues when you try to make use of SharePoint 2010 as opposed to SharePoint 2007. Hopefully you will find some of the adventures I have had enlightening &lt;/p&gt;  &lt;h3&gt;Installation&lt;/h3&gt;  &lt;p&gt;The first one is that the installation and configuration tools just ignore SP2010. This means when you try to create a team project using the process template you get the error:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;“TF249033: The site template is not available for the locale identifier (LCID).” ”The site template name is: SCRUM.”&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;You have to manually download and install the SharePoint template WSP, &lt;a href="http://consultingblogs.emc.com/crispinparker/archive/2011/01/14/scrum-for-team-system-v3-sharepoint-2010-portal.aspx"&gt;as detail in this blog post&lt;/a&gt;. Once the WSP is deployed on your SharePoint 2010 farm you can create new team projects using the process template.&lt;/p&gt;  &lt;h3&gt;How it looks&lt;/h3&gt;  &lt;p&gt;There are problems with the way the site renders. The two major issues are the site actions drop down appears behind the main display area (red box in left screen shot), and on some page large blocks of CSS get rendered to the screen as opposed to being dealt with programmatically (right screen shot).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.blackmarble.co.uk/blogs/rfennell/image_7D9FC38A.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.blackmarble.co.uk/blogs/rfennell/image_thumb_6DB07EC6.png" width="244" height="221" /&gt;&lt;/a&gt;&amp;#160;&lt;a href="http://blogs.blackmarble.co.uk/blogs/rfennell/image_6286F47C.png"&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.blackmarble.co.uk/blogs/rfennell/image_thumb_147E9507.png" width="288" height="223" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Both of these &lt;a href="https://www.scrumforteamsystem.com/QA/Show?id=455"&gt;issues have been reported on the support forum&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;My reading is that the current SFTS SharePoint template WSP has only had minimal changes to port it to SP2010 from SP2007, just enough to get it to load. I think the key issue here maybe that the SFTS SharePoint template has its own master page. This is something all TFS 2005/2008 templates tended to do, but for 2010 there has been a general move to inherit from core SharePoint master pages. Basically the master page structure needs to be rebuild from the ground up by EMC for fix all the issues, but we can address some of them…&lt;/p&gt;  &lt;h4&gt;Change the master page&lt;/h4&gt;  &lt;p&gt;Fixing all the issues in the master page is somewhat daunting as 2007 and 2010 master pages are very different in style. However, after a chat with one of our SharePoint developers it was suggested a better solution is to just tell the site just to use a different master page (one of the SP2010 standard ones). This is a technique we have used on bespoke site upgrades and usually will address most of the issues, then it is a matter of fixing the, hopefully smaller, list of outstanding problems. &lt;/p&gt;  &lt;p&gt;So below is the process to make the change &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Install &lt;a href="http://www.microsoft.com/downloads/en/details.aspx?displaylang=en&amp;amp;FamilyID=d88a1505-849b-4587-b854-a7054ee28d66"&gt;SharePoint Designer 2010&lt;/a&gt; on a PC (this is a free download from Microsoft) &lt;/li&gt;    &lt;li&gt;Logging in as a user with admin rights on the site, open SP2010 Designer and open the url of the Scrum for Team System SharePoint Site e.g. &lt;a href="http://tfsdemo/sites/DefaultCollection/team1"&gt;http://tfsdemo/sites/DefaultCollection/team1&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;In the site objects tree on the left select the master pages node &lt;/li&gt;    &lt;li&gt;You should see four master pages &lt;/li&gt;    &lt;li&gt;Right click on the &lt;strong&gt;v4.master&lt;/strong&gt; and select ‘set as custom master page’ &lt;/li&gt;    &lt;li&gt;Load the site in a browser and it should look like a more normal SP2010 site &lt;/li&gt;    &lt;li&gt;You can swap it back by making the SFTS.master the custom master page&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;a href="http://blogs.blackmarble.co.uk/blogs/rfennell/image_5B67B804.png"&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="image" border="0" alt="image" src="http://blogs.blackmarble.co.uk/blogs/rfennell/image_thumb_6D444BD1.png" width="352" height="285" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Actually on first look the swapping the master page seems to have done the job on the homepage in default view mode without any other edits. However, there are still problem of stray CSS being shown when accessing the other pages, and a trace of green in some of the borders.&lt;/p&gt;  &lt;p&gt;So a partial success, but with more work maybe a complete one? But that is not the route I took.&lt;/p&gt;  &lt;h3&gt;Report Title Click-through&lt;/h3&gt;  &lt;p&gt;Both the SFTS and standard Microsoft reports are displayed in dashboards the same way, they use a page view webpart and the TFSredirect.aspx page. This shows the report chart and a link to take you to its Reporting Services home when the title is clicked. The rendering of the report works for SFTS, but &lt;a href="https://www.scrumforteamsystem.com/QA/Show?id=370"&gt;another reported problem&lt;/a&gt; is that when you click the report title links (highlighted in green in above graphic) you get the error &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;TF250008: This SharePoint site is not currently associated with a team project in Team Foundation Server. To ensure that this site functions correctly, you must configure a team project to refer data for that project to this site. For more information, see this topic on the Microsoft Web site: How to: Add a Team Project Portal. You can use the following querystring argument to specify a specific project: tf:ProjectId. &lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The error says a workaround is to pass the TF:ProjectID parameter in the title URL. This is the only solution I have found. To do this &lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Load SQL Management Studio&lt;/li&gt;    &lt;li&gt;Open the tfs_defaultcollection DB (or the one for your tema project collection) and the tbl_projects table. &lt;/li&gt;    &lt;li&gt;Look for and copy the projectID for the project you want to report on&lt;/li&gt;    &lt;li&gt;Open the SharePoint page with the failing chart. Click the small down triangle in the top right of the webpart to get the webpart editor. &lt;/li&gt;    &lt;li&gt;In the advanced section add &amp;amp;TF%3aPROJECTID={guid} with your {GUID} to the end of the Title URL (the %3a is the : character)&lt;/li&gt;    &lt;li&gt;I also had to remove the &amp;amp;IsDashboard=false else I got a “An attempt was made to set a report parameter &amp;#39;IsDashboard&amp;#39; that is not defined in this report. (rsUnknownReportParameter)” error.&lt;/li&gt;    &lt;li&gt;Press OK to save, the chart should render and the link work&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;Basically the title URL as automatically build is wrong, it has an extra parameter the report does not support and for some reason the automatically passed project ID is being lost. In fact even when you fix the Url is wrong as the report it points to is a dashboard summary when you probably want to take the user to a fuller version of the report. Which of course you could do by altering the Url provided.&lt;/p&gt;  &lt;p&gt;I think the root problem here is that the webpart assumes that the report has a dashboard and full version mode, as many of the MSF agile ones do, so this sort of makes sense.If you reports are single mode you need to pass two Urls.&lt;/p&gt;  &lt;p&gt;Again this editing is all a bit of pain, but you don’t do it too often, and you could also write a command line tool to easily get the GUID. &lt;/p&gt;  &lt;h3&gt;But maybe a better overall option?&lt;/h3&gt;  &lt;p&gt;However, whilst trying all this I realised that the SFTS created SharePoint site does not really do what much ‘special’. Beyond being a basic SharePoint site it has&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;a link to the process guidance, but is just an HTML file that redirects to &lt;a href="http://www.scrumforteamsystem.com/processguidance/v3/"&gt;http://www.scrumforteamsystem.com/processguidance/v3/&lt;/a&gt; so can be added as link&lt;/li&gt;    &lt;li&gt;a link to the Team Web Access, there is a standard webpart for this or you could just use a link&lt;/li&gt;    &lt;li&gt;the front page dashboard, this has the two SFTS chart webparts and a TFS query webpart, but we can recreate this ourselves with the standard TFS webparts&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Therefore I would suggest the best option to avoid all these SharePoint 2007/2010 issues is to manually create a new SharePoint site and add similar controls to those used by SFTS to make the SharePoint site you want. As long as you are not creating new team projects all the time this should not be too much of a problem.&lt;/p&gt;  &lt;p&gt;The steps to do this are as follows:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;In Team Explorer create a new Team Project using STFS template but set it not to create a Sharepoint site (you can always use an existing SFTS Team project if you want in place of this step if it already exist)&lt;/li&gt;    &lt;li&gt;On the default collections SharePoint e.g &lt;a href="http://tfsdemo/sites/DefaultCollection"&gt;http://tfsdemo/sites/DefaultCollection&lt;/a&gt; create a new site (site actions), give it a name e.g. ‘Team1’ so it’s URL is &lt;a href="http://tfsdemo/sites/DefaultCollection/team1"&gt;http://tfsdemo/sites/DefaultCollection/team1&lt;/a&gt;. You can select any site template, but the collaboration/team one would seem a good start, nice and generic&lt;/li&gt;    &lt;li&gt;In Team Explorer select the STFS created in step1 and right click, select team project settings | portal settings&lt;/li&gt;    &lt;li&gt;Check the enable tram project portal (if not already set) press the configure URL and enter the details of the site created in step 2, press OK to exit&lt;/li&gt;    &lt;li&gt;Check the ‘reports and dashboards refer to data for this team project’ checkbox and press OK. &lt;/li&gt;    &lt;li&gt;Return to the web site created in step 2, it is now wired to the correct team project&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;You can now add pages, links and webpart to the web site to build your portal. The most important are&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Adding the set of ‘Visual Studio Team Foundation Server Web Parts’ which provide items such a build list, work item list etc.They should all pickup the correct team project.&lt;/li&gt;    &lt;li&gt;The page viewer that allows redirections via the TFSRedirect.aspx page as detailed above&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;We can also link directly to the reporting services reports using the SQL Server reporting web part. As SFTS does not ship its reports as Excel workbooks we don’t have to consider Excel Services..&lt;/p&gt;  &lt;h3&gt;And finally &lt;/h3&gt;    &lt;p&gt;I hope this post has given you some ideas as to how to address the issues with SFTS 3.0 on SP2010, enough too keep you happy until there is a release of the template what fully supports SP2010.&lt;/p&gt;&lt;img src="http://blogs.blackmarble.co.uk/aggbug.aspx?PostID=22042" width="1" height="1" alt="" /&gt;</description></item><item><title>My upcoming speaking engagements for Spring/Summer 2011</title><link>http://msmvps.com/blogs/rfennell/archive/2011/05/03/my-upcoming-speaking-engagements-for-spring-summer-2011.aspx</link><pubDate>Tue, 03 May 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1792633</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;I have a couple of community speaking engagements coming up&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://edinburgh.bcs.org.uk/events/2010-11/110511.htm"&gt;May 11 BCS Edinburgh on Agile Methods&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href="http://www.nxtgenug.net/ViewEvent.aspx?EventID=415"&gt;July 11 NxtGen Southampton on Test Driven development and mocking&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Both are free, so if you are in the either area, I would be surprised if you were at both given the locations, I hope you can come along&lt;/p&gt;&lt;img src="http://blogs.blackmarble.co.uk/aggbug.aspx?PostID=22037" width="1" height="1" alt="" /&gt;</description></item><item><title>Mocking constructor</title><link>http://msmvps.com/blogs/mehfuz/archive/2011/03/22/mocking-constructor.aspx</link><pubDate>Tue, 22 Mar 2011 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1790346</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;Often we end up in a situation where constructor call on the target type requires us to include&amp;#160; a config file in our test project or requires firing up some external process. To better illustrate this if we create an entity framework data container either new or from an existing database , we will likely to end up with an entry point class that requires either a valid connection string to be passed or if we expand the default constructor we might see this:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:f9640afa-e882-44bb-9ad8-899d09118a58" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background:#ddd;overflow:auto;"&gt; &lt;ol style="background:#000000;margin:0 0 0 2em;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;&lt;/span&gt;&lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#99a38a;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;&lt;/span&gt;&lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#99a38a;"&gt; Initializes a new NorthwindEntities object using the connection string found in the &amp;#39;NorthwindEntities&amp;#39; section of the application configuration file.&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;&lt;/span&gt;&lt;span style="color:#808080;"&gt;///&lt;/span&gt;&lt;span style="color:#99a38a;"&gt; &lt;/span&gt;&lt;span style="color:#808080;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;&lt;/span&gt;&lt;span style="color:#93c763;"&gt;public&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt; NorthwindEntities() : &lt;/span&gt;&lt;span style="color:#93c763;"&gt;base&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;(&lt;/span&gt;&lt;span style="color:#ec7600;"&gt;&amp;quot;name=NorthwindEntities&amp;quot;&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;, &lt;/span&gt;&lt;span style="color:#ec7600;"&gt;&amp;quot;NorthwindEntities&amp;quot;&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#f1f2f3;"&gt;&lt;/span&gt;&lt;span style="color:#93c763;"&gt;this&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;ContextOptions&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;LazyLoadingEnabled &lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;=&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt; &lt;/span&gt;&lt;span style="color:#93c763;"&gt;true&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#f1f2f3;"&gt;OnContextCreated();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The comment clearly shows that by default it will search for&amp;#160; a connection string named “NorthwindEntities” in the configuration file. Though this is not an ideal case where it makes the class more production oriented less TDD friendly (if you think it in a TDD purist way) but to avoid this kind of situation the newest release of Telerik JustMock (Free / Commercial) includes a way to mock such case comprehensively. Thus making it flexible for testers who don’t need to include a configuration file or initialize a default service.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Using the JustMock free edition, I can now easily make the following test pass with the above constructor:&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:b5f10cd4-e0f3-4abe-902f-7b311ab2412e" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background:#ddd;overflow:auto;"&gt; &lt;ol style="background:#000000;margin:0 0 0 2.5em;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;[&lt;/span&gt;&lt;span style="color:#678cb1;"&gt;TestMethod&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;]&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;&lt;/span&gt;&lt;span style="color:#93c763;"&gt;public&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt; &lt;/span&gt;&lt;span style="color:#93c763;"&gt;void&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt; ShouldAssertWhenSaveOperationIsExpected()&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;{&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#f1f2f3;"&gt;&lt;/span&gt;&lt;span style="color:#93c763;"&gt;var&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt; context &lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;=&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt; &lt;/span&gt;&lt;span style="color:#678cb1;"&gt;Mock&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Create&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#678cb1;"&gt;NorthwindEntities&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;(&lt;/span&gt;&lt;span style="color:#678cb1;"&gt;Constructor&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Mocked);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#f1f2f3;"&gt;&lt;/span&gt;&lt;span style="color:#678cb1;"&gt;Mock&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Arrange(() &lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;=&amp;gt;&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt; context&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;SaveChanges(&lt;/span&gt;&lt;span style="color:#678cb1;"&gt;Arg&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;IsAny&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color:#678cb1;"&gt;SaveOptions&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;&amp;gt;&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;()))&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;MustBeCalled();&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#f1f2f3;"&gt;context&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;SaveChanges(&lt;/span&gt;&lt;span style="color:#678cb1;"&gt;SaveOptions&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;AcceptAllChangesAfterSave);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#f1f2f3;"&gt;&lt;/span&gt;&lt;span style="color:#678cb1;"&gt;Mock&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Assert(context);&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;}&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The key here is the &lt;strong&gt;Consturctor.Mocked&lt;/strong&gt; overload in &lt;em&gt;Mock.Create&amp;lt;T&amp;gt;&lt;/em&gt;.&amp;#160; By default it is &lt;strong&gt;NotMocked&lt;/strong&gt; as general&amp;#160; but incase your constructor is throwing some unknown exception and you have little control over its codebase then this could be just it.&lt;/p&gt;  &lt;p&gt;# region Developer’s log:&lt;/p&gt;  &lt;p&gt;As the feature is supported in JustMock free edition, it is right to say that there is no profiler involved. Therefore, it is not possible to use &lt;strong&gt;FormatterServices &lt;/strong&gt;in that regard : &lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:79cd652c-0c69-4ecc-9ed3-d6cfc4a6012a" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background:#ddd;max-height:100px;overflow:auto;"&gt; &lt;ol style="background:#000000;margin:0 0 0 2em;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;&lt;/span&gt;&lt;span style="color:#93c763;"&gt;var&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt; context &lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;=&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt; &lt;/span&gt;&lt;span style="color:#678cb1;"&gt;FormatterServices&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;GetSafeUninitializedObject(&lt;/span&gt;&lt;span style="color:#93c763;"&gt;typeof&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;(&lt;/span&gt;&lt;span style="color:#678cb1;"&gt;NorthwindEntities&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;));&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;If we just open up the &lt;em&gt;NorthwindEntities&lt;/em&gt; class in IL dissembler , we will see something like the one shown below:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:edf85644-6934-4dea-84a0-c78c4e242e2d" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background:#ddd;max-height:500px;overflow:auto;"&gt; &lt;ol style="background:#000000;margin:0 0 0 2.5em;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;IL_0000:  ldarg&lt;/span&gt;&lt;span style="color:#ffcd22;"&gt;.0&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;IL_0001:  ldarg&lt;/span&gt;&lt;span style="color:#ffcd22;"&gt;.1&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;IL_0002:  ldstr      &lt;/span&gt;&lt;span style="color:#ec7600;"&gt;&amp;quot;NorthwindEntities&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;IL_0007:  call       instance &lt;/span&gt;&lt;span style="color:#93c763;"&gt;void&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt; [System&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Data&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Entity]System&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Data&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Objects&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#678cb1;"&gt;ObjectContext&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;::.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;ctor(&lt;/span&gt;&lt;span style="color:#93c763;"&gt;string&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;,&lt;/span&gt;&lt;/li&gt; &lt;li&gt;                                                                                                &lt;span style="color:#f1f2f3;"&gt;&lt;/span&gt;&lt;span style="color:#93c763;"&gt;string&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;IL_000c:  nop&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;IL_000d:  nop&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;IL_000e:  ldarg&lt;/span&gt;&lt;span style="color:#ffcd22;"&gt;.0&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;IL_000f:  call       instance &lt;/span&gt;&lt;span style="color:#93c763;"&gt;class&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt; [System&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Data&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Entity]System&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Data&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Objects&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#678cb1;"&gt;ObjectContextOptions&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt; [System&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Data&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Entity]System&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Data&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Objects&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#678cb1;"&gt;ObjectContext&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;::&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;get_ContextOptions()&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;IL_0014:  ldc&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;i4&lt;/span&gt;&lt;span style="color:#ffcd22;"&gt;.1&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;IL_0015:  callvirt   instance &lt;/span&gt;&lt;span style="color:#93c763;"&gt;void&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt; [System&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Data&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Entity]System&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Data&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;Objects&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;.&lt;/span&gt;&lt;span style="color:#678cb1;"&gt;ObjectContextOptions&lt;/span&gt;&lt;span style="color:#e8e2b7;"&gt;::&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;set_LazyLoadingEnabled(&lt;/span&gt;&lt;span style="color:#93c763;"&gt;bool&lt;/span&gt;&lt;span style="color:#f1f2f3;"&gt;)&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;IL_001a:  nop&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;IL_001b:  nop&lt;/span&gt;&lt;/li&gt; &lt;li&gt;&lt;span style="color:#f1f2f3;"&gt;IL_001c:  ret&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Here on line 4 it is first calling the base constructor which is actually the case for all .net objects. Even If the class has no base, .net framework will still do an instance&lt;em&gt;&amp;#160;&lt;/em&gt;call to System.Object itself.&amp;#160; But it is possible to skip the call during proxy initialization which is on the other hand is not possible in C# if the base class has no default constructor. Of course, this wont work with sealed class in that case profiler is the only resort. Also, Silverlight runtime does not allow it but you can still reference Silverlight class library from .net test project and things will work just nicely.&lt;/p&gt;  &lt;p&gt;#endregion&lt;/p&gt;  &lt;p&gt;Hope that you will find the &lt;strong&gt;Constructor.Mocked &lt;/strong&gt;feature useful. You can download the project for this post here &lt;a href="http://weblogs.asp.net/blogs/mehfuzh/EntityFramework01_017AED4E.zip" target="_blank"&gt;EntityFramework01.zip&lt;/a&gt;. Finally If you like NuGet, you can also try &lt;strong&gt;install-package JustMock&lt;/strong&gt; to grab the latest build.&amp;#160; &lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Thanks&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7729607" width="1" height="1" alt="" /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=3dHTaZZ6d8I:5TaSU6cZSYc:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?d=yIl2AUoC8zA" border="0" alt="" /&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=3dHTaZZ6d8I:5TaSU6cZSYc:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?d=qj6IDK7rITs" border="0" alt="" /&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=3dHTaZZ6d8I:5TaSU6cZSYc:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?d=7Q72WNTAKBA" border="0" alt="" /&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=3dHTaZZ6d8I:5TaSU6cZSYc:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?i=3dHTaZZ6d8I:5TaSU6cZSYc:F7zBnMyn0Lo" border="0" alt="" /&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/burncsharp/~4/3dHTaZZ6d8I" height="1" width="1" alt="" /&gt;</description></item><item><title>Follow up to yesterdays events on ‘enabling agile development with cool tools’</title><link>http://msmvps.com/blogs/rfennell/archive/2011/01/28/follow-up-to-yesterdays-events-on-enabling-agile-development-with-cool-tools.aspx</link><pubDate>Fri, 28 Jan 2011 06:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1787248</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;&lt;em&gt;Thanks to everyone who attended &lt;/em&gt;&lt;a href="http://www.blackmarble.co.uk/events.aspx?event=Enabling%20Agile%20Development%20with%20Cool%20Tools"&gt;&lt;em&gt;yesterdays Black Marble event ‘Enabling agile development with cool tools’&lt;/em&gt;&lt;/a&gt;&lt;em&gt;, both &lt;/em&gt;&lt;a href="http://community.devexpress.com/blogs/garyshort/default.aspx"&gt;&lt;em&gt;Gary Short’s&lt;/em&gt;&lt;/a&gt;&lt;em&gt; and my sessions seemed well received. I was asked if my slides would be available anywhere, well the answer is no. The reason for this is that my session was mostly demo driven, so the slides just set the scene. After a bit of thought, a quick blog post seems a better option;&amp;#160; so this post covers the same basic points as the session. If you are interested in any of the products I would urge you to download them and give them a go. Many are free and all have at least a free fully functional evaluation edition.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;So the essence of my session was on the project management/administrative side of agile projects. The key here is communication both inside and outside of the immediate project team. How to we capture and distribute information so it assists the project not hampers it? &lt;/p&gt;  &lt;p&gt;Traditionally the physical taskboard, with moving moving some form of postcards around has been the answer. This is a great solution as long as the team is co-located and that there is no need for a detailed on going record of the historic state of the tasks (maybe a requirement for legal reasons, but then maybe a daily digital photo would do?). Anyway many teams find they need to capture this information in some electronic form. In my session I looked at some of the options with TFS2010&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;What is built into TFS2010?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;As TFS has a single work item store you can edit work items with a wide variety of clients. In the box you have tools to edit work items via Visual Studio, SharePoint, Team Web Access as well as the ability to manage work items in Excel and Project.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;What if I live in Outlook?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;If you want to do all you work item management in Outlook then have a look at &lt;a href="http://www.ekobit.com/ProductsDetailView.aspx?id=1"&gt;Ekobit’s TeamCompanion&lt;/a&gt;. This in effect allows you to treat work items in a similar manner to email, and cross between the two. So you can create a work item from an email and vice versa; it also allows the managing work items in batches. This product strikes me was very well suited to an email based support desk or project manager that is meeting or email orientated, maybe dealing with people who do not themselves have access to TFS, just email.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;How can I replicate my physical taskboard?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;For many teams the capture of the physical taskboard information is the key. I have always found a good way to make sure TFS work items are up to date is to have all the work items associated with the tasks on the taskboard returned via a TFS query and then in Excel, as the daily stand up is done, make sure each task is up to date. &lt;/p&gt;  &lt;p&gt;However, some people like to work more visually than that, so in the session I looked at a couple of desktop applications that allow work item management both in a form editing manner and via taskboard like drag and drop operations. These were &lt;a href="http://www.telerik.com/community/download-free-products.aspx"&gt;Telerik’s Work Item Manager&lt;/a&gt; and &lt;a href="http://www.scrumforteamsystem.com/version-3/tfs-workbench-v2-1-x64"&gt;EMC’s TFS Work Bench&lt;/a&gt;. &lt;/p&gt;  &lt;p&gt;However for many companies adding another desktop application to a controlled IT PC can be a problem so I also had a look at &lt;a href="http://urbanturtle.com/"&gt;Urban Turtle&lt;/a&gt; an add-in to Team Web Access that allows a more visual taskboard approach with in a browser by adding a couple of tabs to those&amp;#160; in the standard Team Web Access product.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;But what about outside the team?&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;All the products I showed in the first half of the session were in essence work item editors, a team could choose to use any or all of them. This does not however really help with getting information out to interested parties beyond the team; for this we need publically accessible &lt;a href="http://c2.com/cgi/wiki?InformationRadiator"&gt;Information Radiators&lt;/a&gt;. The information on these needs to change over time and be easy to understand. &lt;/p&gt;  &lt;p&gt;The output of the team focused tools may be just what you need here, maybe a chart printed out and stuck to a notice board will do, but there are some other options.&lt;/p&gt;  &lt;p&gt;The first is that there are a rich set of reports in TFS, available both as Reporting Services reports and Excel charts. Reporting Services is particularity interesting as it can deliver reports to interested parties on a scheduled e.g. the CTO get the project burn down emailed as a PDF every Monday morning. There is also the option to deliver reports to central information sites such as Intranet SharePoint servers for everyone to see.&lt;/p&gt;  &lt;p&gt;But what do you do if you want something a bit more striking, something that does not require a person to look on a web site or open their email? Maybe a big screen showing what is going on in the project? I showed two products to do this one was &lt;a href="http://www.telerik.com/community/download-free-products.aspx"&gt;Telerik’s Project Dashboard&lt;/a&gt; and the other a version our &lt;a href="http://blogs.blackmarble.co.uk/blogs/rfennell/archive/2008/12/22/update-in-using-stylecop-in-tfs-team-build.aspx"&gt;Black Marble internal BuildWallboard&lt;/a&gt;, written using the TFS API.    &lt;br /&gt;&lt;/p&gt;  &lt;p&gt;So in summary, in my opinion the key differentiator for TFS over ALM solutions built for a set of different vendors products is that there is a single store for all work items so a wide range of editing an reporting tools can be bought to bear without having to worry over whether the information you are working with is the going to be passed correctly between the various components of the system.&lt;/p&gt;  &lt;p&gt;So again I would urge you that if you use TFS have a look at these product, and the many others that are out there, given them a go and see which ones may assist your process. Remember agile is all about continuous improved isn’t it, so give it a try&lt;/p&gt;&lt;img src="http://blogs.blackmarble.co.uk/aggbug.aspx?PostID=21834" width="1" height="1" alt="" /&gt;</description></item><item><title>How to raise event for a mocked call.</title><link>http://msmvps.com/blogs/mehfuz/archive/2010/10/06/how-to-raise-event-for-a-mocked-call.aspx</link><pubDate>Wed, 06 Oct 2010 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1779442</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;Recently, while i was working with a support issue , i found this interesting piece of test code that i would like to share here. This is actually written by Stefan Lieser (Out from German .net community forwarded to me by Jan from Telerik Germany). As the title states,&amp;#160; it is to mock a specific event for an expected call.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Now Stefan wants to raise an event from &lt;em&gt;WebClient&lt;/em&gt; class of &lt;em&gt;System.Net&lt;/em&gt; for a download operation. Therefore, first the &lt;em&gt;WebClient &lt;/em&gt;class is mocked during setup.&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1ac53c7d-935f-4dd6-9904-626fb7375327" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background:#ddd;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0 0 0 2em;padding:0 0 0 5px;"&gt; &lt;li&gt;[&lt;span style="color:#2b91af;"&gt;SetUp&lt;/span&gt;]&lt;/li&gt; &lt;li class="even"&gt;&lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; Setup()&lt;/li&gt; &lt;li&gt;{&lt;/li&gt; &lt;li class="even"&gt;    webClient = &lt;span style="color:#2b91af;"&gt;Mock&lt;/span&gt;.Create&amp;lt;&lt;span style="color:#2b91af;"&gt;WebClient&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li&gt;}&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;Next the mocking here takes place in two part. First, &lt;em&gt;DownloadDataCompletedEventArgs &lt;/em&gt;is&lt;em&gt;&amp;#160;&lt;/em&gt;mocked to return an expected data when &lt;em&gt;Result&lt;/em&gt; property is get.&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:696facaa-b0b9-4d53-92ff-478c4eb57bbd" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background:#ddd;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0 0 0 2em;padding:0 0 0 5px;"&gt; &lt;li&gt; &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; e = &lt;span style="color:#2b91af;"&gt;Mock&lt;/span&gt;.Create&amp;lt;&lt;span style="color:#2b91af;"&gt;DownloadDataCompletedEventArgs&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li class="even"&gt; &lt;/li&gt; &lt;li&gt; &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; data = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[] { 1, 2, 3 };&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt; &lt;span style="color:#2b91af;"&gt;Mock&lt;/span&gt;.Arrange(() =&amp;gt; e.Result).Returns(data);&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;This is followed by an arrange that will raise the expected event when &lt;em&gt;DownloadDataAsync&lt;/em&gt; is invoked.&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:852a124c-eec9-4e16-9ccb-a7e839fd03ef" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background:#ddd;max-height:300px;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0 0 0 2em;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#2b91af;"&gt;Mock&lt;/span&gt;.Arrange(() =&amp;gt; webClient.DownloadDataAsync(&lt;span style="color:#2b91af;"&gt;Arg&lt;/span&gt;.IsAny&amp;lt;&lt;span style="color:#2b91af;"&gt;Uri&lt;/span&gt;&amp;gt;()))&lt;/li&gt; &lt;li class="even"&gt;    .Raises(() =&amp;gt; webClient.DownloadDataCompleted += &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;, e);&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Finally, the whole test method ends up like:&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:204f8759-1c9f-410e-928e-63f51ccd42d1" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background:#ddd;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;"&gt; &lt;li&gt;  [&lt;span style="color:#2b91af;"&gt;Test&lt;/span&gt;]&lt;/li&gt; &lt;li class="even"&gt;  &lt;span style="color:#0000ff;"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;void&lt;/span&gt; ShouldAssertExepectedDataWhenDownloadIsCompleted()&lt;/li&gt; &lt;li&gt;  {&lt;/li&gt; &lt;li class="even"&gt;      &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; count = 0;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li class="even"&gt;      &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; e = &lt;span style="color:#2b91af;"&gt;Mock&lt;/span&gt;.Create&amp;lt;&lt;span style="color:#2b91af;"&gt;DownloadDataCompletedEventArgs&lt;/span&gt;&amp;gt;();&lt;/li&gt; &lt;li&gt;      &lt;/li&gt; &lt;li class="even"&gt;      &lt;span style="color:#0000ff;"&gt;var&lt;/span&gt; data = &lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[] { 1, 2, 3 };&lt;/li&gt; &lt;li&gt;     &lt;/li&gt; &lt;li class="even"&gt;      &lt;span style="color:#2b91af;"&gt;Mock&lt;/span&gt;.Arrange(() =&amp;gt; e.Result).Returns(data);&lt;/li&gt; &lt;li&gt;     &lt;/li&gt; &lt;li class="even"&gt;      &lt;span style="color:#2b91af;"&gt;Mock&lt;/span&gt;.Arrange(() =&amp;gt; webClient.DownloadDataAsync(&lt;span style="color:#2b91af;"&gt;Arg&lt;/span&gt;.IsAny&amp;lt;&lt;span style="color:#2b91af;"&gt;Uri&lt;/span&gt;&amp;gt;()))&lt;/li&gt; &lt;li&gt;          .Raises(() =&amp;gt; webClient.DownloadDataCompleted += &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;, &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;, e);&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;      &lt;span style="color:#0000ff;"&gt;byte&lt;/span&gt;[] exepectedData = &lt;span style="color:#0000ff;"&gt;null&lt;/span&gt;;&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;      webClient.DownloadDataCompleted += &lt;span style="color:#0000ff;"&gt;delegate&lt;/span&gt;(&lt;span style="color:#0000ff;"&gt;object&lt;/span&gt; sender, &lt;span style="color:#2b91af;"&gt;DownloadDataCompletedEventArgs&lt;/span&gt; de)  &lt;/li&gt; &lt;li class="even"&gt;      {&lt;/li&gt; &lt;li&gt;          exepectedData = de.Result;&lt;/li&gt; &lt;li class="even"&gt;          count++; &lt;/li&gt; &lt;li&gt;      };&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;      webClient.DownloadDataAsync(&lt;span style="color:#0000ff;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Uri&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;http://example.de&amp;quot;&lt;/span&gt;));&lt;/li&gt; &lt;li class="even"&gt;&amp;nbsp;&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li class="even"&gt;      &lt;span style="color:#2b91af;"&gt;Assert&lt;/span&gt;.That(count, &lt;span style="color:#2b91af;"&gt;Is&lt;/span&gt;.EqualTo(1));&lt;/li&gt; &lt;li&gt;      &lt;span style="color:#2b91af;"&gt;Assert&lt;/span&gt;.That(exepectedData.Length, &lt;span style="color:#2b91af;"&gt;Is&lt;/span&gt;.EqualTo(data.Length));&lt;/li&gt; &lt;li class="even"&gt;  }&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The above example is done using JustMock SP1. You can further download the code here:    &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:F60BB8FA-6F02-4999-8F5E-9DD4E92C4DA7:6586fdab-3fae-4176-9bf5-b7b19728d3fd" class="wlWriterEditableSmartContent"&gt;&lt;div&gt;&lt;a href="http://weblogs.asp.net/blogs/mehfuzh/WebClientTest001_3EC161FD.zip" target="_blank"&gt;WebClientTest001.zip&lt;/a&gt;&lt;/div&gt;&lt;/div&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Happy coding !!&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7624213" width="1" height="1" alt="" /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=SJrzCjYH3b0:9suN2D7Rl7Q:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?d=yIl2AUoC8zA" border="0" alt="" /&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=SJrzCjYH3b0:9suN2D7Rl7Q:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?d=qj6IDK7rITs" border="0" alt="" /&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=SJrzCjYH3b0:9suN2D7Rl7Q:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?d=7Q72WNTAKBA" border="0" alt="" /&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=SJrzCjYH3b0:9suN2D7Rl7Q:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?i=SJrzCjYH3b0:9suN2D7Rl7Q:F7zBnMyn0Lo" border="0" alt="" /&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/burncsharp/~4/SJrzCjYH3b0" height="1" width="1" alt="" /&gt;</description></item><item><title>Back to school : Getting to know F#</title><link>http://msmvps.com/blogs/mehfuz/archive/2010/08/13/back-to-school-getting-to-know-f.aspx</link><pubDate>Fri, 13 Aug 2010 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1775889</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;This post starts with a basic introduction of F# and finally ends up writing a simple unit test for an F# member. For those who don’t know what F# is all about, Its a product from Microsoft research and now part of VS 2010 family. Actually from Wikipedia it is described as follows:&lt;/p&gt;  &lt;p&gt;&lt;em&gt;F# (pronounced F Sharp) is a multi-paradigm programming language, targeting the .NET Framework, that encompasses functional programming as well as imperative object-oriented programming disciplines. It is a variant of ML and is largely compatible with the OCaml implementation. F# was initially developed by Don Syme at Microsoft Research but is now being developed at Microsoft Developer Division and is being distributed as a fully supported language in the .NET Framework and Visual Studio as part of Visual Studio 2010.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;Now, let’s first start by creating an F# project using the built in VS template:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/mehfuzh/WindowsLiveWriter/GettingstartedmockingwithF_BB2E/image_2.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/mehfuzh/WindowsLiveWriter/GettingstartedmockingwithF_BB2E/image_thumb.png" width="619" height="411" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Once you hit ok, It will end you up with an empty module project like that follows:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/mehfuzh/WindowsLiveWriter/GettingstartedmockingwithF_BB2E/image_4.png"&gt;&lt;img style="border-right-width:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/mehfuzh/WindowsLiveWriter/GettingstartedmockingwithF_BB2E/image_thumb_1.png" width="621" height="392" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now, first of all what is a module in F# ? From MSDN library it is stated as:&lt;/p&gt;  &lt;p&gt;&lt;em&gt;In the context of the F# language, a module is a grouping of F# code, such as values, types, and function values, in an F# program. Grouping code in modules helps keep related code together and helps avoid name conflicts in your program.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;But, it looks to me rather a namespace in C#. Next let’s create the first type in F#. &lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e133e3b2-2ab1-492d-9cfb-8e0878d00063" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background:#ddd;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0 0 0 2em;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;type&lt;/span&gt; IMonkey = &lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff;"&gt;interface&lt;/span&gt;&lt;/li&gt; &lt;li&gt;       &lt;span style="color:#0000ff;"&gt;abstract&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;member&lt;/span&gt; Name : string &lt;span style="color:#0000ff;"&gt;with&lt;/span&gt; set, get&lt;/li&gt; &lt;li class="even"&gt;       &lt;span style="color:#0000ff;"&gt;abstract&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;member&lt;/span&gt; Echo : unit &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; int&lt;/li&gt; &lt;li&gt;       &lt;span style="color:#0000ff;"&gt;abstract&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;member&lt;/span&gt; Execute : unit &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; unit&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff;"&gt;end&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In F# there everything is type , if you mark it as interface then use the interface or class keyword. Here is in the code block, we can also see that the first member is declared using the &lt;em&gt;with &lt;/em&gt;keyword followed by set, get which states that its a read/write property. The second member has &lt;em&gt; :unit-&amp;gt; int&lt;/em&gt; , it means that it takes no argument and returns an integer value. Now, what if we had an argument, then the declaration would look like:&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:07e068c9-3f2e-47ac-ab38-c0ec0e16f9e5" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background:#ddd;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0 0 0 2em;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;abstract&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;member&lt;/span&gt; Echo : arg1 : int &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; int&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Moving on to multiple arguments, it needs to be written in a tupled way:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;   &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:1c59934f-b8e0-470f-a7f7-8703608eeb83" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background:#ddd;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0 0 0 2em;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;abstract&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;member&lt;/span&gt; Echo : arg1 : int * arg2:int &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; int&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;The question remains it’s an interface but how we can declare class members . To find out more lets consider this:&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a9b8ff6e-788e-4dce-8e5e-d841d837b6ab" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background:#ddd;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0 0 0 2em;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;type&lt;/span&gt; Foo = &lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt;&lt;/li&gt; &lt;li&gt;      &lt;span style="color:#0000ff;"&gt;member&lt;/span&gt; this.Echo(arg1 : int) =&lt;/li&gt; &lt;li class="even"&gt;         10&lt;/li&gt; &lt;li&gt;      &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;member&lt;/span&gt; EchoStatic() = 20&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff;"&gt;end&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Here, type declaration is as expected has a &lt;em&gt;class&lt;/em&gt; keyword. But for members there is one instance method and one static method. One returns 10 and another returns&amp;#160; 20 but first one has arguments too.&amp;#160; The declaration is slightly different for implemented or class members where the assigned value acts as a return value and you have to specify the argument(s) via colon format and using commas like:&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:831d186a-343b-4f80-9449-1610ad6d8a8b" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background:#ddd;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0 0 0 2em;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;member&lt;/span&gt; this.Echo(arg1 : int, arg2: int) = 100&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Of course you have to specify &lt;em&gt;this &lt;/em&gt;keyword to let F#&amp;#160; know that its an instance member. Now, moving further what would happen if I would implement “IMonky” interface to “Foo” class.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c7a81532-7f0e-40fa-94fe-1efeb97421e0" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background:#ddd;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;type&lt;/span&gt; Foo = &lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff;"&gt;class&lt;/span&gt;&lt;/li&gt; &lt;li&gt;    &lt;span style="color:#0000ff;"&gt;interface&lt;/span&gt; IMonkey &lt;span style="color:#0000ff;"&gt;with&lt;/span&gt;&lt;/li&gt; &lt;li class="even"&gt;        &lt;span style="color:#0000ff;"&gt;member&lt;/span&gt; this.Echo() = 10&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff;"&gt;member&lt;/span&gt; this.Execute() = ()&lt;/li&gt; &lt;li class="even"&gt;        &lt;span style="color:#0000ff;"&gt;member&lt;/span&gt; this.Name &lt;span style="color:#0000ff;"&gt;with&lt;/span&gt; get() = &lt;span style="color:#800000;"&gt;&amp;quot;test&amp;quot;&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff;"&gt;member&lt;/span&gt; this.Name &lt;span style="color:#0000ff;"&gt;with&lt;/span&gt; set(arg1 : string) = ()&lt;/li&gt; &lt;li class="even"&gt;        &lt;span style="color:#0000ff;"&gt;end&lt;/span&gt;&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff;"&gt;member&lt;/span&gt; this.Echo(arg1 : int) =&lt;/li&gt; &lt;li class="even"&gt;         10&lt;/li&gt; &lt;li&gt;        &lt;span style="color:#0000ff;"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff;"&gt;member&lt;/span&gt; EchoStatic() = 20&lt;/li&gt; &lt;li class="even"&gt;    &lt;span style="color:#0000ff;"&gt;end&lt;/span&gt;&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Here, for each interface implemented should be wrapped with the following block :&lt;/p&gt;  &lt;p&gt;interface &amp;lt;name&amp;gt; with&lt;/p&gt;  &lt;p&gt;//&amp;#160; your implementation.&lt;/p&gt;  &lt;p&gt;end&lt;/p&gt;  &lt;p&gt;Another thing to notice here that how property getter and setter is implemented using the &lt;em&gt;with&lt;/em&gt; keyword. Moreover, the assignment with empty parenthesis&amp;#160; like &lt;em&gt;member this.Execute() = ()&amp;#160; &lt;/em&gt;marks that the method is returning anything or a void method.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;As we are set with declaring an interface, its members and how it is implemented. Now, lets write an unit test that mocks a member of it. I will be using JustMock here but can be done using other tools like NSubstitute (The new player in town) / Rhino. To do so, first we need to add the following lines before the type and following the module declaration.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0e0883ec-80dc-418a-91c9-26a203668642" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background:#ddd;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0 0 0 2em;padding:0 0 0 5px;"&gt; &lt;li&gt;&lt;span style="color:#0000ff;"&gt;open&lt;/span&gt; NUnit.Framework&lt;/li&gt; &lt;li class="even"&gt;&lt;span style="color:#0000ff;"&gt;open&lt;/span&gt; Telerik.JustMock&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Its similar to an &lt;em&gt;using&lt;/em&gt; keyword in C#. I am skipping the class declaration and adding instance member into it that can be done in the same way as shown above. Therefore, directly pasting the following code:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;div style="padding-bottom:0px;margin:0px;padding-left:0px;padding-right:0px;display:inline;float:none;padding-top:0px;" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:98415c06-4e94-4fe5-912b-f84180683ed4" class="wlWriterEditableSmartContent"&gt; &lt;div class="le-pavsc-container"&gt; &lt;div style="background:#ddd;overflow:auto;"&gt; &lt;ol style="background:#ffffff;margin:0 0 0 2.5em;padding:0 0 0 5px;"&gt; &lt;li&gt;  [&amp;lt;Test()&amp;gt;]&lt;/li&gt; &lt;li class="even"&gt;  &lt;span style="color:#0000ff;"&gt;member&lt;/span&gt; this.ShouldMockMethodCallsWithReturn() =&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li class="even"&gt;      &lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; monkey = Mock.Create&amp;lt;IMonkey&amp;gt;()&lt;/li&gt; &lt;li&gt;     &lt;/li&gt; &lt;li class="even"&gt;      Mock.Arrange(monkey, &lt;span style="color:#0000ff;"&gt;fun&lt;/span&gt; ignore &lt;span style="color:#0000ff;"&gt;-&amp;gt;&lt;/span&gt; monkey.Echo()).Returns(10).MustBeCalled()  &lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li class="even"&gt;      &lt;span style="color:#0000ff;"&gt;let&lt;/span&gt; result = monkey.Echo()&lt;/li&gt; &lt;li&gt;&amp;nbsp;&lt;/li&gt; &lt;li class="even"&gt;      Mock.Assert(monkey)&lt;/li&gt; &lt;/ol&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;One of the interesting piece here is the variable assignment which is done using &lt;em&gt;let &lt;/em&gt;keyword. it’s same like doing this in C#:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;var monkey&amp;#160; = Mock.Create&amp;lt;IMonkey&amp;gt;(); &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;In &lt;em&gt;Mock.Arrange&lt;/em&gt;&amp;#160; the &lt;em&gt;fun ignore –&amp;gt; monkey.Echo()&amp;#160; &lt;/em&gt;is equivalent to&amp;#160; () =&amp;gt; monkey.Echo() in C# but can’t use the () as it means differently in F# therefore used an anonymous variable instead.&amp;#160; Everything else is plain old vanilla and hope this introduction to F# helped you a bit that additionally shows a first unit test written with it.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Enjoy!!&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7591536" width="1" height="1" alt="" /&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=SxmoVpXJN_0:5y3jVcLpoMs:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?d=yIl2AUoC8zA" border="0" alt="" /&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=SxmoVpXJN_0:5y3jVcLpoMs:qj6IDK7rITs"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?d=qj6IDK7rITs" border="0" alt="" /&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=SxmoVpXJN_0:5y3jVcLpoMs:7Q72WNTAKBA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?d=7Q72WNTAKBA" border="0" alt="" /&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/burncsharp?a=SxmoVpXJN_0:5y3jVcLpoMs:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/burncsharp?i=SxmoVpXJN_0:5y3jVcLpoMs:F7zBnMyn0Lo" border="0" alt="" /&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/burncsharp/~4/SxmoVpXJN_0" height="1" width="1" alt="" /&gt;</description></item><item><title>Fun presenting last night at BCS</title><link>http://msmvps.com/blogs/rfennell/archive/2010/07/01/fun-presenting-last-night-at-bcs.aspx</link><pubDate>Thu, 01 Jul 2010 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1772956</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;Thanks to everyone who attended my session last night at the West Yorkshire BCS on Agile and Lean development process. The projector failing after only a few minutes meant I had to adopt a good agile approach to the session. It was nice that so many people came up afterwards to say they enjoyed the lack of PowerPoint.&lt;/p&gt;  &lt;p&gt;This got me thinking, as I enjoyed not having it as well. All I really missed was a couple of slides one that showed a Kanban board and another that diagrammatically showed the Scrum process, I got round the lack of both of these by pointing wildly at the blank projector screen and asking people to imagine. So if I run that session again I think I will just have that pair of slides and lose the rest. I just need to find a nice means to let me see the text slides, which I used as my speaking notes. I have never been a fan of postcard style notes when presenting, too much to drop, and when I tried using my phone in the past it was awkward, but maybe time to try again now my phone has a larger screen.&lt;/p&gt;  &lt;p&gt;If you do want to see the slides you missed they will be going on on the &lt;a href="http://www.westyorkshire.bcs.org/"&gt;West Yorkshire BCS site&lt;/a&gt; ASAP&lt;/p&gt;&lt;img src="http://blogs.blackmarble.co.uk/aggbug.aspx?PostID=21400" width="1" height="1" alt="" /&gt;</description></item><item><title>Speaking at the BCS this week on Agile</title><link>http://msmvps.com/blogs/rfennell/archive/2010/06/28/speaking-at-the-bcs-this-week-on-agile.aspx</link><pubDate>Mon, 28 Jun 2010 05:00:00 GMT</pubDate><guid isPermaLink="false">d67277c4-116b-43f1-b688-e9ef184ea916:1772818</guid><dc:creator>Anonymous</dc:creator><description>&lt;p&gt;Just a reminder I am speaking at the West Yorkshire BCS meeting this Wednesday on the subject ‘A&lt;a href="http://www.westyorkshire.bcs.org/2010/05/31/agile-is-so-old-hat-all-the-cool-kids-are-doing-lean-now/"&gt;gile is so old hat all the cool kids are doing lean now’&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;The meeting starts a 5:45 for refreshments, and 6:30 for my session. The venue is the Old Broadcasting House, 148 Woodhouse Lane, Leeds LS2 9EN (&lt;a href="http://www.ntileeds.co.uk"&gt;www.ntileeds.co.uk&lt;/a&gt;)&lt;/p&gt;  &lt;p&gt;Hope to see you there&lt;/p&gt;&lt;img src="http://blogs.blackmarble.co.uk/aggbug.aspx?PostID=21396" width="1" height="1" alt="" /&gt;</description></item></channel></rss>