<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>One Man's Walk in work &#187; c#</title>
	<atom:link href="http://onemanswalk.com/work/tag/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://onemanswalk.com/work</link>
	<description>jeremy lightsmith on agile, ruby, and consulting</description>
	<lastBuildDate>Wed, 08 Sep 2010 05:57:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Fun with Closures in C# 2.0</title>
		<link>http://onemanswalk.com/work/2006/06/22/fun-with-closures-in-c-2-0/</link>
		<comments>http://onemanswalk.com/work/2006/06/22/fun-with-closures-in-c-2-0/#comments</comments>
		<pubDate>Thu, 22 Jun 2006 19:34:00 +0000</pubDate>
		<dc:creator>jeremy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[	One of my favorite features in C# 2.0 are the anonymous delegates.  Your code starts to almost look like ruby  .  But hold on, they can be tricky.

	Can you find the bug here?

	
Button&#91;&#93; digits = new Button&#91;&#93; &#123;Zero, One, Two, Three&#125;;
for &#40;int i = 0; i



	&#8212;&#8212;
Give up?

	After executing this code, clicking any [...]]]></description>
			<content:encoded><![CDATA[	<p>One of my favorite features in C# 2.0 are the anonymous delegates.  Your code starts to almost look like ruby <img src='http://onemanswalk.com/work/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> .  But hold on, they can be tricky.</p>

	<p>Can you find the bug here?</p>

	<p>
<div class="wp_syntax"><div class="code"><pre class="ruby">Button<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> digits = new Button<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>Zero, One, Two, Three<span style="color:#006600; font-weight:bold;">&#125;</span>;
<span style="color:#9966CC; font-weight:bold;">for</span> <span style="color:#006600; font-weight:bold;">&#40;</span>int i = <span style="color:#006666;">0</span>; i</pre></div></div>
</p>


	<p>&#8212;&#8212;<br />
Give up?</p>

	<p>After executing this code, clicking any button would result in this ClickDigit being called with the value of 4 instead of the appropriate value between 0 and 3.<br />
&#8212;&#8212;<br />
I groaned when I realized what it was.  ClickDigit gets called with <em>i</em> in the state it is in when the button gets clicked &#8211; <strong>not</strong> when the event handler was attached.</p>

	<p>Once you realize this, it&#8217;s very simple to fix it, even if it looks kind of strange.</p>

	<p>So it should be :</p>

	<p>
<div class="wp_syntax"><div class="code"><pre class="ruby">Button<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> digits = new Button<span style="color:#006600; font-weight:bold;">&#91;</span><span style="color:#006600; font-weight:bold;">&#93;</span> <span style="color:#006600; font-weight:bold;">&#123;</span>Zero, One, Two, Three<span style="color:#006600; font-weight:bold;">&#125;</span>;
<span style="color:#9966CC; font-weight:bold;">for</span> <span style="color:#006600; font-weight:bold;">&#40;</span>int i = <span style="color:#006666;">0</span>; i</pre></div></div>
</p>


 ]]></content:encoded>
			<wfw:commentRss>http://onemanswalk.com/work/2006/06/22/fun-with-closures-in-c-2-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Intelli J For Dot Net Is Out</title>
		<link>http://onemanswalk.com/work/2004/02/17/intelli-j-for-dot-net-is-out/</link>
		<comments>http://onemanswalk.com/work/2004/02/17/intelli-j-for-dot-net-is-out/#comments</comments>
		<pubDate>Tue, 17 Feb 2004 00:00:00 +0000</pubDate>
		<dc:creator>jeremy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[intellij]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[	Jet Brains are calling it Resharper.  I&#8217;ve been waiting, drooling, for a year over just the rumors that such a thing was in development.

	Be warned, it&#8217;s the first cut of a first cut of a first cut.  It throws lots of exceptions, and has a very small subset of intellij&#8217;s features.  If [...]]]></description>
			<content:encoded><![CDATA[	<p>Jet Brains are calling it Resharper.  I&#8217;ve been waiting, drooling, for a year over just the rumors that such a thing was in development.</p>

	<p>Be warned, it&#8217;s the first cut of a first cut of a first cut.  It throws lots of exceptions, and has a very small subset of intellij&#8217;s features.  If you&#8217;re looking for a polished product, wait a bit, it will come, but it&#8217;s not here yet.</p>

	<p>However, I damn near cried when I typed &#8216;AssertE&#8217; control-tab, and it completed it &#8216;!AssertEquals();&#8217; putting my cursor in the middle of the the parens.  I love the Jet Brains guys.  For my part, I&#8217;m going to use it, and submit bugs, and help them turn out another product that puts the rest of the industry to shame..</p>

	<p>To download it or even just check it out &#8211;  http://www.jetbrains.net/resharper user/password is eapuser/eapuser</p>
 ]]></content:encoded>
			<wfw:commentRss>http://onemanswalk.com/work/2004/02/17/intelli-j-for-dot-net-is-out/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using NFit</title>
		<link>http://onemanswalk.com/work/2003/08/25/using-nfit/</link>
		<comments>http://onemanswalk.com/work/2003/08/25/using-nfit/#comments</comments>
		<pubDate>Mon, 25 Aug 2003 00:00:00 +0000</pubDate>
		<dc:creator>jeremy</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[nfit]]></category>
		<category><![CDATA[projects]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[	So I&#8217;ve started committing some of the tweaks I&#8217;ve made to the .net version of FIT into
the sourceforge project Steve Freeman and I started at http://sourceforge.net/projects/nfit/.
I&#8217;d like to talk about how my team structures its code around FIT.

	For context, this is a c# project, and we&#8217;re using VS.Net, NAnt, and !SLiNgshot to build, along w/ [...]]]></description>
			<content:encoded><![CDATA[	<p>So I&#8217;ve started committing some of the tweaks I&#8217;ve made to the .net version of <span class="caps">FIT</span> into<br />
the sourceforge project Steve Freeman and I started at http://sourceforge.net/projects/nfit/.<br />
I&#8217;d like to talk about how my team structures its code around <span class="caps">FIT</span>.</p>

	<p>For context, this is a c# project, and we&#8217;re using VS.Net, NAnt, and !SLiNgshot to build, along w/ the usual suspects:<br />
NUnit, !CruiseControl.Net, etc.</p>

	<p>Directory Structure&#8212;&#8212;<br />
We have a directory structure that looks like :</p>
	<ul>
		<li>doc/</li>
		<li>Iteration1/</li>
		<li><story name>.html  &#8211;  all tests associated w/ a story</li>
		<li><story name>.html</li>
		<li>Iteration2/</li>
		<li><story name>.html</li>
		<li>Iteration3/</li>
		<li>stories.html  &#8211;  list of all stories in an !AllFiles like fixture</li>
		<li>lib/</li>
		<li>src/</li>
		<li>project 1/</li>
		<li>project 2/</li>
		<li>fit/</li>
		<li>run.aspx  &#8211;  copied from nfit</li>
		<li>custom fixture 1.cs  &#8211;  fixture used in a fit test</li>
		<li>custom fixture 2.cs</li>
		<li>project 3/</li>
		<li>foo.sln  &#8211;  solution file</li>
	</ul>

	<p>We&#8217;ve argued a lot over what the structure of the source should look like on a .net project, and our current solution is a src dir, inside of which is one dir for each project and a solution file.  It&#8217;s flat and easy to see where everything is.</p>

	<p>All the <span class="caps">FIT</span> tests go into the <strong>doc</strong> dir.  <strong>fit</strong> is a VS web project that references all the other projects, along w/ the <span class="caps">FIT</span> dll&#8217;s.  It includes all the fixtures our tests will need and the run.aspx file from NFit.</p>


	<p>Running <span class="caps">FIT </span>Dynamically&#8212;&#8212;<br />
We&#8217;ve found it totally necessary to be able to run fit tests dynamically in addition to<br />
running them from command line.  Ward has his <strong>run.cgi</strong> on http://fit.c2.com/ to let you click &#8216;run&#8217; on a fit test.  I&#8217;ve just checked in <strong>Run.aspx</strong> into NFit which will let you do the same thing.</p>

	<p>This is how we use it:</p>

	<p>We have 2 webshares.  */doc* points to our &#8216;doc&#8217; directory and holds all the tests.  */fit* points to our &#8216;src/fit&#8217; directory and holds our copy of <strong>Run.aspx</strong> along w/ all the code our tests run against.  We put a run link at the top of each test that points to &#8216;/fit/run.aspx&#8217;, and when we browse our tests we do it through our local <span class="caps">IIS</span> using something like &#8216;http://localhost/doc/stories.html&#8217;.</p>

	<p>Because fit is just another project along w/ all our other projects in VS, we get linking,<br />
debugging, and building for free inside and outside visual studio.</p>


	<p>Structuring <span class="caps">FIT </span>Tests&#8212;&#8212;<br />
When you&#8217;re writing so-called &#8216;acceptance tests&#8217;, it&#8217;s important to remember that there are several different missions of testing and types of tests to achieve them.  The way you structure your tests should reflect this, see default.WhatAboutAcceptanceTesting</p>

	<p>In the doc directory, we group our tests in files by the story they test against, and the stories by the iterations they are completed (or scheduled to be completed) in. This of course makes the assumption that all tests &#8220;belong&#8221; to one and only one story.  Up until now that&#8217;s been okay, we&#8217;ll probably add another place to put tests when and if that becomes a problem.  It has been good to teach our team to think about testing functionality in terms the customer can see.</p>

	<p>Now we <em>could</em> just run all our tests automatically, but we wanted one page that everyone could<br />
go to to see our teams status.  So we take the spreadsheet of stories that our client keeps complete with<br />
their points, their iteration, and their status (done or not).  And we point to it with an aspx page to<br />
provide an html view that fit can run against.  So when you go to http://localhost/doc/, you see a table for<br />
every iteration, each of which contains all the tests in that iteration.  Only ones that have been marked<br />
done in the spreadsheet get run.</p>

	<p>So we have one page that tells you the status of all stories we&#8217;ve ever done.  And it tells you how we&#8217;re doing<br />
on the current iteration as well &#8211; along w/ our velocity of course <img src='http://onemanswalk.com/work/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />&#8212;&#8212;How about if my return value is an <span class="caps">XML</span> document, how does <span class="caps">FIT</span> deal with that. How do I pass two parameters to a method.</p>

	<p><span class="caps">TIA</span></p>
 &#8211; Yazid Arezki
 ]]></content:encoded>
			<wfw:commentRss>http://onemanswalk.com/work/2003/08/25/using-nfit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
