<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0"><channel><title>ISerializable - Roy Osherove's  Blog : Art Of Unit Testing</title><link>http://weblogs.asp.net/rosherove/archive/tags/Art+Of+Unit+Testing/default.aspx</link><description>Tags: Art Of Unit Testing</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/ArtOfUnitTesting" type="application/rss+xml" /><feedburner:emailServiceId xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">ArtOfUnitTesting</feedburner:emailServiceId><feedburner:feedburnerHostname xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">http://feedburner.google.com</feedburner:feedburnerHostname><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item><title>Test driven design – Willed vs. Forced Designs</title><link>http://weblogs.asp.net/rosherove/archive/2009/11/12/test-driven-design-willed-vs-forced-designs.aspx</link><pubDate>Thu, 12 Nov 2009 21:59:48 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7252833</guid><dc:creator>RoyOsherove</dc:creator><slash:comments>0</slash:comments><wfw:commentRss>http://weblogs.asp.net/rosherove/rsscomments.aspx?PostID=7252833</wfw:commentRss><comments>http://weblogs.asp.net/rosherove/archive/2009/11/12/test-driven-design-willed-vs-forced-designs.aspx#comments</comments><description>&lt;p&gt;I’m writing this as a typemock employee, but also as someone who has sat on the other side of the line for several good years, and can argue in both ways. The following, I feel, is true no matter where I work.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;There are two ways people use tests to drive design, as far as I see. one is great, and I agree with, the other is not so great and I don’t agree with it. Sadly, both of them are categorized together these days, and the baby gets thrown out with the bath water - You either use both (BAD) or you use neither (BAD!)&lt;/p&gt;  &lt;p&gt;Here are the two usage patterns:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;#1 Willed Design&lt;/strong&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;By writing tests, you can observe the usability of your design from a consumer perspective, and can decide whether or not you like it, and change it accordingly&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&lt;strong&gt;#2 Forced Design&lt;/strong&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;By using a subset of the available isolation frameworks(rhino, moq, nmock) or specific techniques *manual mocks and stubs) you discover cases that are not technically “mockable” or “fakeable” and use that as a sign for design change.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;I highly agree with #1, and highly disagree with #2.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;#1 makes sense.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You get to decide what is a good and bad design, and the experience of using that design from the test perspective is your guideline. But &lt;strong&gt;you&lt;/strong&gt; make the rules on what you like and don’t like.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;#2 is problematic for several reasons:&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The tool decides. Not you.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;You let an automated tool (rhino mocks, Moq etc..) tell you when your design is OK or not. That point alone should go against anything ALT.NET has ever stood for, doesn’t it? If you need a tool to tell you what is good or bad design, then you &lt;strong&gt;are doing it wrong&lt;/strong&gt;. You should either know good design beforehad, or you shoud pair program together to find the best design, or you should learn by a mentor who can review your design mistakes, but don’t ever let a tool tell you what is right and what isn’t, especially when the only reason that tool works for that is by chance and not on purpose&amp;#160; (as you’ll see in the next point)&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;A technical limitation that grew into something else&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;tools like rhino and MOQ and NMOCK &lt;strong&gt;just happen&lt;/strong&gt; to support some OO ideas that seem good enough for design activities because of the underlying technology they use underneath. It’s pretty simple – they all use some form of either generating code at runtime that inherits from a class or interface, and then overrides methods on it (therefore they need to be virtual methods and non sealed classes, or an interface) or they use a proxy of some kind which underneath does pretty much the same things. (typemock is an exception since it uses a profiler api which has non of these requirements) . &lt;strong&gt;simply that means&lt;/strong&gt; that the reason rhino, or MOQ or NMOCK “let you know” that you should use an interface somewhere, is a technical limitation of the tools, not a choice. Ayende was asked once what he’d do if he was technically able to fake static methods in rhino mocks – would he add that feature? “in the blink of an eye” he answered. and I agree. adding more options to the tool just extends the limitations of the possible design under test, not the “goodness” of it.&lt;/p&gt;  &lt;p&gt;Languages like Ruby, Javascript, Python etc.. have isolation frameworks (or in some cases don’t even need such frameworks) that fully support any type of behavior changing, regardless of the design, since the language is less strict. yet, somehow, proper design arises in those languages tool. perhaps those languages are just “too powerful” and should not be used because they will cause you to do bad design? see the previous point for my answer.&lt;/p&gt;  &lt;p&gt;What happens if tomorrow, or using C# 4.0 those tools get such abilities? will you all stop using them?&lt;/p&gt;  &lt;p&gt;of course, you don’t have to use isolation frameworks to be dissuaded by the idea of limiting your design by using something – in this case a technique: using manual mocks and stubs in an object oriented language is just as “limiting” technically as is using one of those frameworks. You’re still bound to play within the simple laws of OO and using a design that is even a little out of place (even though it might make perfect sense for your application for security, performance or other reasons) is either untestable, or a general no no. &lt;/p&gt;  &lt;p&gt;see the previous point for what i think about that. &lt;/p&gt;  &lt;p&gt;the point here is that you’re using a technical limitation of a tool or a technique to tell you what to do instead of thinking for yourself and learning proper design guidelines. that limitation &lt;strong&gt;just happens&lt;/strong&gt; to be somewhat partially consistent with what you might currently to believe to be true for design. but technically, it is a limitation that could end soon. when it changes it’s behavior, will you just change your design guidelines? switch or won’t upgrade to a new version of the language? or actually start using your head and your peers to see what’s right and what’s not?&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Typemock Dilemma&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Typemock gets a lot of flack for not inhibiting the design of the program, and I can see how people would be afraid to lose that limitation in other tools, since all they head from alpha geeks in .NET is that if it’s not “testable” then your design is wrong. worse, they hear “if you need typemock your design is wrong”. &lt;/p&gt;  &lt;p&gt;there’s nothing a silly as absolute “fact” theories in the software world. In fact, let me go out and say that &lt;strong&gt;all fact theories are wrong&lt;/strong&gt;. How that’s for irony?&lt;/p&gt;  &lt;p&gt;The message should be, I feel, more like “here are some principles of good design as we think of it today”, but instead it is based on tool choice and not on technicques or craftsmanship.&lt;/p&gt;  &lt;p&gt;Unfortunately, I don’t think getting rid of #2 is possible in .NET today without using a tool like typemock, and that’s a shame, since it means that, because it costs money, people in the community will still want to use the free tools, which force design, instead of allowing them to decide on it like the mature developers they are.&lt;/p&gt;  &lt;p&gt;Maybe it’s time to have some sort of free version of Isolator so that everyone can benefit. what do you think?&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7252833" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rosherove/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Testing+Guidelines/default.aspx">Testing Guidelines</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Agile/default.aspx">Agile</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Art+Of+Unit+Testing/default.aspx">Art Of Unit Testing</category></item><item><title>Art of Unit Testing on Hanselminutes</title><link>http://weblogs.asp.net/rosherove/archive/2009/07/07/art-of-unit-testing-on-hanselminutes.aspx</link><pubDate>Tue, 07 Jul 2009 12:28:40 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7142874</guid><dc:creator>RoyOsherove</dc:creator><slash:comments>5</slash:comments><wfw:commentRss>http://weblogs.asp.net/rosherove/rsscomments.aspx?PostID=7142874</wfw:commentRss><comments>http://weblogs.asp.net/rosherove/archive/2009/07/07/art-of-unit-testing-on-hanselminutes.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rosherove/image_5D7B81D7.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; margin: 0px 10px 0px 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" align="left" src="http://weblogs.asp.net/blogs/rosherove/image_thumb_27F98A51.png" width="193" height="244" /&gt;&lt;/a&gt; &lt;a href="http://www.hanselman.com/blog/"&gt;Scott Hanselman&lt;/a&gt; took me in for a 30 minute interview about Unit Testing Dos and Don’ts in his podcast, Hanselminutes. It was a pleasure, and I hope to be there once more about other topics. Maybe in TechEd Berlin..&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.hanselminutes.com/default.aspx?showID=187"&gt;Have a listen&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7142874" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rosherove/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Agile/default.aspx">Agile</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Art+Of+Unit+Testing/default.aspx">Art Of Unit Testing</category></item><item><title>NDC 2009 – Done!</title><link>http://weblogs.asp.net/rosherove/archive/2009/06/22/ndc-2009-done.aspx</link><pubDate>Mon, 22 Jun 2009 11:46:14 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7131932</guid><dc:creator>RoyOsherove</dc:creator><slash:comments>5</slash:comments><wfw:commentRss>http://weblogs.asp.net/rosherove/rsscomments.aspx?PostID=7131932</wfw:commentRss><comments>http://weblogs.asp.net/rosherove/archive/2009/06/22/ndc-2009-done.aspx#comments</comments><description>&lt;p&gt;NDC 2009 was a blast!&lt;/p&gt;  &lt;p&gt;Thanks for all the great conversations :)&lt;/p&gt;  &lt;p&gt;Here’s what it looked like when you look up at a full room in NDC&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rosherove/DSC03827_0DB4B286.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="DSC03827" border="0" alt="DSC03827" src="http://weblogs.asp.net/blogs/rosherove/DSC03827_thumb_7D78C4BF.jpg" width="543" height="708" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rosherove/DSC03826_3D12FB85.jpg"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="DSC03826" border="0" alt="DSC03826" src="http://weblogs.asp.net/blogs/rosherove/DSC03826_thumb_06E15D69.jpg" width="750" height="578" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7131932" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rosherove/archive/tags/Agile/default.aspx">Agile</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Art+Of+Unit+Testing/default.aspx">Art Of Unit Testing</category></item><item><title>Questions every team and dev lead should ask themselves</title><link>http://weblogs.asp.net/rosherove/archive/2009/06/16/questions-every-team-and-dev-lead-should-ask-themselves.aspx</link><pubDate>Tue, 16 Jun 2009 05:43:34 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7126581</guid><dc:creator>RoyOsherove</dc:creator><slash:comments>10</slash:comments><wfw:commentRss>http://weblogs.asp.net/rosherove/rsscomments.aspx?PostID=7126581</wfw:commentRss><comments>http://weblogs.asp.net/rosherove/archive/2009/06/16/questions-every-team-and-dev-lead-should-ask-themselves.aspx#comments</comments><description>&lt;p&gt;here are the questions that teams and team leads should be asking themselves on a daily\weekly basis.&lt;/p&gt;  &lt;p&gt;There are more, but these are the basics, to me. It’s part of the summary for the talk “Beautiful teams I am giving at SEConf and NDC. we do a lot of this stuff &lt;a href="http://www.typemock.com"&gt;over at work&lt;/a&gt;, and it’s proving itself on a daily basis.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Whole team&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;What can we automate?&lt;/li&gt;    &lt;li&gt;where are we &amp;quot;Reinventing the wheel&amp;quot;?&lt;/li&gt;    &lt;li&gt;what are the tools that slow us down?&lt;/li&gt;    &lt;li&gt;what tools can we use better?&lt;/li&gt;    &lt;li&gt;are there bugs that I could have found earlier? how do I make sure I find them earlier?&lt;/li&gt;    &lt;li&gt;when do we find out we built the right thing?&lt;/li&gt;    &lt;li&gt;when do we find out our code\design sucks? how can we make that earlier?&lt;/li&gt;    &lt;li&gt;How do we show progress at the team level? at the management level?&lt;/li&gt;    &lt;li&gt;How many meetings does each dev have every week? how can we remove them?&lt;/li&gt;    &lt;li&gt;Are we building by feature or by layer?&lt;/li&gt;    &lt;li&gt;can we make all our team sit in the same place? &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Team Lead&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;daily: what bottlenecks exist in the team? what have I solved?&lt;/li&gt;    &lt;li&gt;will my devs be better in a month or two than they were before? if not, how do I make that happen?&lt;/li&gt;    &lt;li&gt;what prevents my devs from working? what am I doing about this? &lt;/li&gt; &lt;/ol&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7126581" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rosherove/archive/tags/Agile/default.aspx">Agile</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Art+Of+Unit+Testing/default.aspx">Art Of Unit Testing</category></item><item><title>Art Of Unit Testing available at Amazon</title><link>http://weblogs.asp.net/rosherove/archive/2009/06/06/art-of-unit-testing-available-at-amazon.aspx</link><pubDate>Sun, 07 Jun 2009 00:43:57 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7110468</guid><dc:creator>RoyOsherove</dc:creator><slash:comments>10</slash:comments><wfw:commentRss>http://weblogs.asp.net/rosherove/rsscomments.aspx?PostID=7110468</wfw:commentRss><comments>http://weblogs.asp.net/rosherove/archive/2009/06/06/art-of-unit-testing-available-at-amazon.aspx#comments</comments><description>&lt;p&gt;My book, &lt;a href="http://www.amazon.com/exec/obidos/ASIN/1933988274/iserializable-20"&gt;The Art Of Unit Testing&lt;/a&gt;, is now &lt;strong&gt;in stock&lt;/strong&gt; at Amazon. If you’ve read the book, I’d love it if you &lt;a href="http://www.amazon.com/exec/obidos/ASIN/1933988274/iserializable-20"&gt;put in a review on that page.&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7110468" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rosherove/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Agile/default.aspx">Agile</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Art+Of+Unit+Testing/default.aspx">Art Of Unit Testing</category></item><item><title>Using Explicit Arrange,Act,Assert scopes in tests – thoughts?</title><link>http://weblogs.asp.net/rosherove/archive/2009/06/02/using-explicit-arrange-act-assert-scopes-in-tests-thoughts.aspx</link><pubDate>Wed, 03 Jun 2009 00:55:11 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7106613</guid><dc:creator>RoyOsherove</dc:creator><slash:comments>17</slash:comments><wfw:commentRss>http://weblogs.asp.net/rosherove/rsscomments.aspx?PostID=7106613</wfw:commentRss><comments>http://weblogs.asp.net/rosherove/archive/2009/06/02/using-explicit-arrange-act-assert-scopes-in-tests-thoughts.aspx#comments</comments><description>&lt;p&gt;What are your thoughts on this style of writing? &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Specifically the “Explicit” way of defining arrange, act and assert scopes.&lt;/li&gt;    &lt;li&gt;also, given the name of the test, where should the call to “OnApplyTemplate” be (if you’ve never seen the code)?&lt;/li&gt;    &lt;li&gt;which version makes more sense to you? A, or B?&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;version A:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rosherove/image_1782D79C.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/rosherove/image_thumb_6AC9F7F5.png" width="575" height="416" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;version B:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rosherove/image_2C348482.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://weblogs.asp.net/blogs/rosherove/image_thumb_062EAE5F.png" width="564" height="412" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7106613" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rosherove/archive/tags/.Net+2.0/default.aspx">.Net 2.0</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Agile/default.aspx">Agile</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Art+Of+Unit+Testing/default.aspx">Art Of Unit Testing</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Testing that an event was raised</title><link>http://weblogs.asp.net/rosherove/archive/2009/05/23/testing-that-an-event-was-raised.aspx</link><pubDate>Sat, 23 May 2009 18:25:20 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7095427</guid><dc:creator>RoyOsherove</dc:creator><slash:comments>2</slash:comments><wfw:commentRss>http://weblogs.asp.net/rosherove/rsscomments.aspx?PostID=7095427</wfw:commentRss><comments>http://weblogs.asp.net/rosherove/archive/2009/05/23/testing-that-an-event-was-raised.aspx#comments</comments><description>&lt;p&gt;This question keeps coming up: “How can I test that an event was actually raised from my class under test?”&lt;/p&gt;  &lt;p&gt;actually, there is an easy way to check if an event was raised.    &lt;br /&gt;you subscribe to the event in your test, and in the event handler you set a boolean flag to true. then you just assert on the flag.     &lt;br /&gt;here is a quick example: &lt;/p&gt;  &lt;p&gt;&lt;b&gt;Code:&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#800000"&gt;public void Test()      &lt;br /&gt;{       &lt;br /&gt;bool wasRaised=false;       &lt;br /&gt;var button = new Button;       &lt;br /&gt;button.Click += ()=&amp;gt; wasRaised=true;       &lt;br /&gt;button.DoSomethingThatShouldHaveTriggeredTheEvent();       &lt;br /&gt;Assert.IsTrue(wasRaised);       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;If you feel less comfortable using lambdas:&lt;/b&gt; &lt;/p&gt;  &lt;p&gt;&lt;font color="#800000" face="c"&gt;public void Test()      &lt;br /&gt;{       &lt;br /&gt;bool wasRaised=false;       &lt;br /&gt;var button = new Button;       &lt;br /&gt;button.Click += delegate&lt;/font&gt;&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;font color="#800000" face="c"&gt;{ &lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#800000" face="c"&gt;wasRaised=true&lt;/font&gt;&lt;/p&gt;    &lt;p&gt;&lt;font color="#800000" face="c"&gt;};&lt;/font&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;   &lt;br /&gt;&lt;font color="#800000" face="c"&gt;button.DoSomethingThatShouldHaveTriggeredTheEvent();      &lt;br /&gt;Assert.IsTrue(wasRaised);       &lt;br /&gt;}&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Unfortunately, with VB.NET’s current version, doing this in a single method is next to impossible, so you are forced to register to the event with a method at the class level, and check that:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Code (VB.NET):&lt;/b&gt; &lt;/p&gt; &lt;font color="#800000" face="Consolas"&gt;dim wasRaised as Boolean=false;    &lt;br /&gt;&lt;/font&gt;  &lt;p&gt;&lt;font color="#800000" face="Consolas"&gt;&lt;strong&gt;public sub test()        &lt;br /&gt;&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#800000" face="Consolas"&gt;wasRaised=false     &lt;br /&gt;dim button = new Button()      &lt;br /&gt;AddHandler( button.Click , AddressOf(OnClick))&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#800000" face="Consolas"&gt;button.DoSomethingThatShouldHaveTriggeredTheEvent()     &lt;br /&gt;Assert.IsTrue(wasRaised);      &lt;br /&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#800000" face="Consolas"&gt;&lt;strong&gt;end sub&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#800000" face="Consolas"&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#800000" face="Consolas"&gt;&lt;strong&gt;public sub OnClick(source as object,e as EventArgs)&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#800000" face="Consolas"&gt;wasRaised=true&lt;/font&gt;&lt;/p&gt;  &lt;p&gt;&lt;font color="#800000" face="Consolas"&gt;&lt;strong&gt;end sub&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7095427" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rosherove/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Agile/default.aspx">Agile</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Art+Of+Unit+Testing/default.aspx">Art Of Unit Testing</category></item><item><title>Art Of Unit Testing (The Samurai Book)– Get it now, it’s done.</title><link>http://weblogs.asp.net/rosherove/archive/2009/05/20/art-of-unit-testing-the-samurai-book-get-it-now-it-s-done.aspx</link><pubDate>Wed, 20 May 2009 21:22:14 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:7093756</guid><dc:creator>RoyOsherove</dc:creator><slash:comments>16</slash:comments><wfw:commentRss>http://weblogs.asp.net/rosherove/rsscomments.aspx?PostID=7093756</wfw:commentRss><comments>http://weblogs.asp.net/rosherove/archive/2009/05/20/art-of-unit-testing-the-samurai-book-get-it-now-it-s-done.aspx#comments</comments><description>&lt;p&gt;The time has actually come. After 2.5 years, and two kids, &lt;a href="http://www.manning.com/affiliate/idevaffiliate.php?id=462_91" target="_blank"&gt;my book is finally done&lt;/a&gt; and is available in full form as an EBook. at the end of the month it will be in print form. Now would be the time to get it, when it is still at a “pre-order” pricing. Get the preorder price either &lt;a href="http://www.manning.com/affiliate/idevaffiliate.php?id=462_91" target="_blank"&gt;at Manning&lt;/a&gt;(along with the EBook) or at &lt;a href="http://www.amazon.com/exec/obidos/ASIN/1933988274/iserializable-20" target="_blank"&gt;the amazon page&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;I love the cover image. How about we call this “The Samurai book” from now on?&lt;/p&gt;  &lt;p&gt;This is the book that I wished I had when I started out writing my first tests, and that combines my knowledge about unit testing from the past 5-6 years or so working with companies on real projects (and real failures).&lt;/p&gt;  &lt;p&gt;It contains things I have not seen in other places – writing readable, maintainable and trustworthy tests, as well as guidelines on how to review someone else’s tests and what to watch out for.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.manning.com/affiliate/idevaffiliate.php?id=462_91" target="_blank"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" title="image" border="0" alt="image" align="left" src="http://weblogs.asp.net/blogs/rosherove/image_6E3CE98B.png" width="273" height="347" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;I was lucky to have the foreword written by no other than &lt;a href="http://www.amazon.com/exec/obidos/ASIN/0131177052/iserializable-20" target="_blank"&gt;Michael-Legacy-Code-Feathers&lt;/a&gt; himself, and with some great quotes including one from Kent Beck about the book.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Here is the &lt;a href="http://www.manning.com/osherove/excerpt_contents.html" target="_blank"&gt;Table of Contents&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Free Chapters&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The book comes with two free chapters:&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Chapter 1 &lt;/strong&gt;– &lt;a href="http://www.manning.com/osherove/SampleChapter1.pdf" target="_blank"&gt;The basics of unit testing(PDF)&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Chapter 3 &lt;/strong&gt;– &lt;a href="http://www.manning.com/osherove/SampleChapter3.pdf" target="_blank"&gt;Using Stubs to Break Dependencies (PDF)&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Or &lt;a href="http://www.manning.com/affiliate/idevaffiliate.php?id=462_91" target="_blank"&gt;get the full book&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Book description:&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Unit testing, done right, can mean the difference between a failed project and a successful one, between a maintainable code base and a code base that no one dares touch, and between getting home at 2 AM or getting home in time for dinner, even before a release deadline.&lt;/p&gt;  &lt;p&gt;&lt;i&gt;The Art of Unit Testing&lt;/i&gt; builds on top of what's already been written about this important topic. It guides you step by step from simple tests to tests that are maintainable, readable, and trustworthy. It covers advanced subjects like mocks, stubs, and frameworks such as Typemock Isolator and Rhino Mocks. And you'll learn about advanced test patterns and organization, working with legacy code and even untestable code. The book discusses tools you need when testing databases and other technologies. It's written for .NET developers but others will also benefit from this book.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;What’s inside:&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Test Review Guidelines &lt;/li&gt;    &lt;li&gt;How to create readable, maintainable, trustworthy tests &lt;/li&gt;    &lt;li&gt;Stubs, mock objects, and automated frameworks &lt;/li&gt;    &lt;li&gt;Working with .NET tools, including NUnit, Rhino Mocks and Typemock Isolator &lt;/li&gt; &lt;/ul&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=7093756" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rosherove/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Agile/default.aspx">Agile</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Art+Of+Unit+Testing/default.aspx">Art Of Unit Testing</category></item><item><title>Test Review #3 – Unity</title><link>http://weblogs.asp.net/rosherove/archive/2009/03/23/test-review-3-unity.aspx</link><pubDate>Mon, 23 Mar 2009 05:58:55 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6994263</guid><dc:creator>RoyOsherove</dc:creator><slash:comments>11</slash:comments><wfw:commentRss>http://weblogs.asp.net/rosherove/rsscomments.aspx?PostID=6994263</wfw:commentRss><comments>http://weblogs.asp.net/rosherove/archive/2009/03/23/test-review-3-unity.aspx#comments</comments><description>&lt;p&gt;&lt;strong&gt;Watch previous videos:&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://weblogs.asp.net/rosherove/archive/2009/03/20/test-review-1-nerddinner.aspx"&gt;Test Review #1 – NerdDinner&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;&lt;a href="http://weblogs.asp.net/rosherove/archive/2009/03/21/test-review-2-asp-net-mvc-unit-tests.aspx"&gt;Test Review #2 – ASP.NET MVC&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt; &lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="437" height="370" id="viddler_RoyOsherove_6"&gt;&lt;param name="wmode" value="transparent" /&gt;&lt;param name="movie" value="http://www.viddler.com/player/43373a0e/" /&gt;&lt;param name="allowScriptAccess" value="always" /&gt;&lt;param name="allowFullScreen" value="true" /&gt;&lt;embed src="http://www.viddler.com/player/43373a0e/" wmode="transparent" width="437" height="370" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" name="viddler_RoyOsherove_6" /&gt;&lt;/embed&gt;&lt;/object&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;In this video I go over the tests for Microsoft Unity Application Block.&lt;/p&gt;  &lt;p&gt;Overall the quality of the tests in Unity is pretty good! I could certainly recommend that people look at them as examples of a bunch of tests against a framework, which are mostly very readable and maintainable. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Things I walk through:&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Using [Ignore] &lt;/li&gt;    &lt;li&gt;exploration testing &lt;/li&gt;    &lt;li&gt;magic numbers and strings &lt;/li&gt;    &lt;li&gt;un-needed asserts &lt;/li&gt;    &lt;li&gt;Stub hard coded behavior &lt;/li&gt;    &lt;li&gt;handling config files in tests &lt;/li&gt;    &lt;li&gt;Asserts hidden in a utility method &lt;/li&gt;    &lt;li&gt;more naming conventions &lt;/li&gt;    &lt;li&gt;Separating integration tests &lt;/li&gt;    &lt;li&gt;“smart” code that is less readable &lt;/li&gt;    &lt;li&gt;Meaningless “isNotNull” tests &lt;/li&gt;    &lt;li&gt;cleaner ways of expecting exceptions &lt;/li&gt; &lt;/ul&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6994263" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rosherove/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Testing+Guidelines/default.aspx">Testing Guidelines</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Agile/default.aspx">Agile</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Art+Of+Unit+Testing/default.aspx">Art Of Unit Testing</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/TestReview/default.aspx">TestReview</category></item><item><title>Test Review #2 – ASP.NET MVC Unit Tests</title><link>http://weblogs.asp.net/rosherove/archive/2009/03/21/test-review-2-asp-net-mvc-unit-tests.aspx</link><pubDate>Sun, 22 Mar 2009 03:42:38 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6988868</guid><dc:creator>RoyOsherove</dc:creator><slash:comments>18</slash:comments><wfw:commentRss>http://weblogs.asp.net/rosherove/rsscomments.aspx?PostID=6988868</wfw:commentRss><comments>http://weblogs.asp.net/rosherove/archive/2009/03/21/test-review-2-asp-net-mvc-unit-tests.aspx#comments</comments><description>&lt;p&gt;See other reviews: &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://weblogs.asp.net/rosherove/archive/2009/03/20/test-review-1-nerddinner.aspx"&gt;Review #1: NerdDinner&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Here’s the second video review of Unit Tests. This is another one written by Microsoft – &lt;a href="http://www.codeplex.com/aspnet"&gt;ASP.NET MVC&lt;/a&gt; (&lt;a href="http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24471"&gt;source&lt;/a&gt;). &lt;/p&gt;  &lt;p&gt;First, it’s important to state how surprised I was by the &lt;strong&gt;high quality&lt;/strong&gt; of the tests in MVC. The tests are &lt;strong&gt;readable, maintainable and trustworthy, &lt;/strong&gt;with very little issues that I could find. whatever Issues I found are rather easy to fix. In any case, if one is looking for examples of systems written in what seems almost entirely in TDD, or at the minimum with very good testing guidance, ASP.NET MVC should be a good stop to look at.&lt;/p&gt;  &lt;p&gt;&lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="437" height="370" id="viddler"&gt;&lt;param name="movie" value="http://www.viddler.com/player/a30fe2d4/" /&gt;&lt;param name="allowScriptAccess" value="always" /&gt;&lt;param name="allowFullScreen" value="true" /&gt;&lt;param name="wmode" value="transparent" /&gt;&lt;embed src="http://www.viddler.com/player/a30fe2d4/" width="437" height="370" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" wmode="transparent" name="viddler"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;  &lt;p&gt;Issues discussed in this video:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Implementing RowTest with MSTest, and the importance of naming (14:00)&lt;/li&gt;    &lt;li&gt;Verify() that is splitted from the mock expectations (17:00)&lt;/li&gt;    &lt;li&gt;some naming conventions&lt;/li&gt;    &lt;li&gt;Over-specification in tests (mainly more than one mock object per test)&lt;/li&gt;    &lt;li&gt;verifying mocks when it’s not required&lt;/li&gt;    &lt;li&gt;logic inside tests (concatenation)&lt;/li&gt;    &lt;li&gt;test factory methods with too much logic&lt;/li&gt;    &lt;li&gt;a very good example of when &lt;strong&gt;multiple asserts&lt;/strong&gt; is really bad (11:50)&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Again – I’m very pleased with the test quality. Now is the time to make sure the things above are fixed. they are still important!&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6988868" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rosherove/archive/tags/.Net+Original/default.aspx">.Net Original</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/.Net+2.0/default.aspx">.Net 2.0</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Testing+Guidelines/default.aspx">Testing Guidelines</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Agile/default.aspx">Agile</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Art+Of+Unit+Testing/default.aspx">Art Of Unit Testing</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/TestReview/default.aspx">TestReview</category></item><item><title>Test Review #1 - NerdDinner</title><link>http://weblogs.asp.net/rosherove/archive/2009/03/20/test-review-1-nerddinner.aspx</link><pubDate>Fri, 20 Mar 2009 11:45:53 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6981302</guid><dc:creator>RoyOsherove</dc:creator><slash:comments>43</slash:comments><wfw:commentRss>http://weblogs.asp.net/rosherove/rsscomments.aspx?PostID=6981302</wfw:commentRss><comments>http://weblogs.asp.net/rosherove/archive/2009/03/20/test-review-1-nerddinner.aspx#comments</comments><description>&lt;p&gt;I’ve decided to start doing some test reviews of tests that I see in the wild. I figured it’s the best way to show people what I mean when I say they do not have readable, maintainable or trustworthy tests.&lt;/p&gt;  &lt;p&gt;The first episode is the review of the tests from the &lt;a href="http://nerddinner.codeplex.com/"&gt;NerdDinner MVC source code&lt;/a&gt;. It’s 30 minutes long. and it was shot at 2AM, so I’m quite cranky. But the tests sure don’t try to ease my mind, and only make me crankier. &lt;/p&gt;  &lt;p&gt;If you have tests you’d like me to review send an email to Roy AT osherove.com with the subject “Test Review [project name]”&lt;/p&gt;  &lt;p&gt;&lt;object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="437" height="370" id="viddler"&gt;&lt;param name="movie" value="http://www.viddler.com/player/6180e63a/" /&gt;&lt;param name="allowScriptAccess" value="always" /&gt;&lt;param name="allowFullScreen" value="true" /&gt;&lt;param name="wmode" value="transparent" /&gt;&lt;embed src="http://www.viddler.com/player/6180e63a/" width="437" height="370" type="application/x-shockwave-flash" allowScriptAccess="always" allowFullScreen="true" wmode="transparent" name="viddler"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;problems that are dealt with in this video:&lt;/strong&gt;&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Naming conventions&lt;/li&gt;    &lt;li&gt;Magic strings in tests&lt;/li&gt;    &lt;li&gt;Hard coded values in hand written stubs&lt;/li&gt;    &lt;li&gt;Magic assertions (expecting a value that no one understand why it should be that value)&lt;/li&gt;    &lt;li&gt;Lack of tests&lt;/li&gt; &lt;/ul&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6981302" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rosherove/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Agile/default.aspx">Agile</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Art+Of+Unit+Testing/default.aspx">Art Of Unit Testing</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/TestReview/default.aspx">TestReview</category></item><item><title>API design values and decision matrix</title><link>http://weblogs.asp.net/rosherove/archive/2009/03/17/api-design-values-and-decision-matrix.aspx</link><pubDate>Tue, 17 Mar 2009 14:56:56 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6970509</guid><dc:creator>RoyOsherove</dc:creator><slash:comments>5</slash:comments><wfw:commentRss>http://weblogs.asp.net/rosherove/rsscomments.aspx?PostID=6970509</wfw:commentRss><comments>http://weblogs.asp.net/rosherove/archive/2009/03/17/api-design-values-and-decision-matrix.aspx#comments</comments><description>&lt;p&gt;We’ve come to a nice way of deciding upon features in the Isolator API. This is what happens when your end product is an API for programmers.&lt;/p&gt;  &lt;p&gt;First, we realized that we &lt;a href="http://www.elilopian.com/2009/03/12/management-for-geeks-have-a-good-fight/"&gt;must argue about it&lt;/a&gt;. For each type of new feature in the isolator API, we put up on the white board several version of the API that we can’t seem to decide about, and then ask everyone on the team to say what they think. If everyone agrees, then we ask people to defend the opposite side and explain why an API is not good.&lt;/p&gt;  &lt;p&gt;We came to several agreed upon values for the C# API, that help us judge the usability of it:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Consistency – is the new API consistent with the other APIs that already exist, or does it go against the regular way things are done? &lt;/li&gt;    &lt;li&gt;Discoverability – If a user knew they wanted to do thing X, would they know to use the API without help? simply from intellisense? &lt;/li&gt;    &lt;li&gt;Explicitness – we decided early on to be as explicit as possible about the API, so that the least guessing needs to take place by the user &lt;/li&gt;    &lt;li&gt;Single point of entry – everything should start from a single point (Isolate.Something()) &lt;/li&gt;    &lt;li&gt;Readability for the reader, not the writer (if you didn’t write the test would you find it easy to understand what it does?) &lt;/li&gt;    &lt;li&gt;Single way to achieve things – is there more than one way to do a task with the new API? &lt;/li&gt;    &lt;li&gt;Backwards compatibility – do we break an existing feature and cause some heartache&amp;#160; for users? &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;We measure the various versions of an API by putting it in a matrix and setting “V” or “X” on each of them (if we can’t agree it’s a V with a line on it).&lt;/p&gt;  &lt;p&gt;then we have a better idea of what makes more sense.&lt;/p&gt;  &lt;p&gt;I admit we still haven’t come up with a single set of values for the VB API, but I’ll try to define it here:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Does not require use of Action&amp;lt;T&amp;gt;&lt;/li&gt;    &lt;li&gt;Consistent with the way a VBer would use other APIs&lt;/li&gt;    &lt;li&gt;Explicit&lt;/li&gt;    &lt;li&gt;Readable&lt;/li&gt;    &lt;li&gt;Single way to achieve things&lt;/li&gt;    &lt;li&gt;Backwards compatible&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;note that “single point of entry” is not included. That was a design decision we made early on.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6970509" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rosherove/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Agile/default.aspx">Agile</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Art+Of+Unit+Testing/default.aspx">Art Of Unit Testing</category></item><item><title>Art of unit Testing goes to print in April</title><link>http://weblogs.asp.net/rosherove/archive/2009/03/16/art-of-unit-testing-goes-to-print-in-april.aspx</link><pubDate>Mon, 16 Mar 2009 23:33:45 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6968598</guid><dc:creator>RoyOsherove</dc:creator><slash:comments>9</slash:comments><wfw:commentRss>http://weblogs.asp.net/rosherove/rsscomments.aspx?PostID=6968598</wfw:commentRss><comments>http://weblogs.asp.net/rosherove/archive/2009/03/16/art-of-unit-testing-goes-to-print-in-april.aspx#comments</comments><description>&lt;p&gt;The &lt;a href="http://www.ArtOfUnitTesting.com"&gt;book of never ending production&lt;/a&gt; is now actually near the end. &lt;/p&gt;  &lt;p&gt;the projected print date of “Art Of Unit Testing” is now April 30 and I’m happy to see the &lt;a href="http://www.amazon.com/exec/obidos/ASIN/1933988274/iserializable-20"&gt;Amazon page for the book&lt;/a&gt; already has one review of the &lt;a href="http://www.manning.com/affiliate/idevaffiliate.php?id=462_91"&gt;early access version&lt;/a&gt; (though he &lt;a href="http://www.amazon.com/Must-Have-Books-for-your-shelf/forum/Fx3HZHLJNJKXXLK/Tx23FXJ7W0JBTWI/1/ref=cm_cd_dp_tft_tp?_encoding=UTF8&amp;amp;asin=1933988274&amp;amp;store=books"&gt;totally destroys my spelling and book formatting abilities&lt;/a&gt;, he likes the content, so I’m happy)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://www.manning.com/affiliate/idevaffiliate.php?id=462_91"&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/rosherove/image_5FC0326C.png" width="244" height="244" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6968598" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rosherove/archive/tags/Agile+Related/default.aspx">Agile Related</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Agile/default.aspx">Agile</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Art+Of+Unit+Testing/default.aspx">Art Of Unit Testing</category></item><item><title>Unit Testing in silverlight land with Typemock Isolator</title><link>http://weblogs.asp.net/rosherove/archive/2008/12/27/unit-testing-in-silverlight-land-with-typemock-isolator.aspx</link><pubDate>Sat, 27 Dec 2008 21:54:07 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6808150</guid><dc:creator>RoyOsherove</dc:creator><slash:comments>7</slash:comments><wfw:commentRss>http://weblogs.asp.net/rosherove/rsscomments.aspx?PostID=6808150</wfw:commentRss><comments>http://weblogs.asp.net/rosherove/archive/2008/12/27/unit-testing-in-silverlight-land-with-typemock-isolator.aspx#comments</comments><description>&lt;p&gt;I’ve been asked quite a lot recently whether one can write unit tests and isolate logical code that runs inside a silverlight application. Up until today my initial answer was&amp;#160; ‘no’ because silverlight runs under different versions of mscorlib.dll.&lt;/p&gt;  &lt;p&gt;however.&lt;/p&gt;  &lt;p&gt;Today I actually gave it a try and realized that writing unit tests (not &lt;a href="http://www.jeff.wilcox.name/2008/03/silverlight2-unit-testing/"&gt;integration tests, as the silverlight test framework&lt;/a&gt; allows) against silverlight based code is possible and quite easy. Just like any other code that relies on a third party platform (like sharepoint code) the silverlight related code might have various dependencies.&lt;/p&gt;  &lt;p&gt;I’m going to show how to use &lt;a href="http://www.typemock.com"&gt;Typemock Isolator&lt;/a&gt; to overcome a couple of simple silverlight dependencies (using HtmlPage) and how to setup a test project against a silverlight project (with NUnit or MsTest)&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Assumptions:&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;You have an open solution&lt;/li&gt;    &lt;li&gt;the solution contains a silverlight class library or silverlight application project&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#800080"&gt;To setup a test project against silverlight using MSTest:&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Add a new test project to the solution&lt;/li&gt;    &lt;li&gt;Remove all the existing classes (Database test, ordered test etc..) so that you are only left with the unit test class (UnitTest1). &lt;/li&gt;    &lt;li&gt;Remove all useless comments and crud code from the test class so that you are only left with a test method (no comments, not even the TestContext)&lt;/li&gt;    &lt;li&gt;Add a reference to the silverlight versions of “System.dll”, “System.Windows.dll” to the test project. (usually located under “C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\” (remove existing reference to system.dll if you need to first)&lt;/li&gt;    &lt;li&gt;Add a reference to the project under test&lt;/li&gt;    &lt;li&gt;You can now write tests against the object model (standard classes)&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#800080"&gt;To setup a test project against silverlight using NUnit or MbUnit:&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Add a new class library to the solution as your test project&lt;/li&gt;    &lt;li&gt;Add a reference to the silverlight versions of “System.dll”, “System.Windows.dll” to the test project. (usually located under “C:\Program Files\Microsoft SDKs\Silverlight\v2.0\Reference Assemblies\” (remove existing reference to system.dll if you need to first)&lt;/li&gt;    &lt;li&gt;Add a reference to the project under test&lt;/li&gt;    &lt;li&gt;You can now write tests against the object model (standard classes)&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;font color="#800080"&gt;How to break the dependencies&lt;/font&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Now, here is a simple example of code that has a silverlight dependency we’d like to test:&lt;/p&gt;  &lt;p&gt;Let’s say we have a class in the silverlight project called ChatSession (I’m basing this on ScottGu’s Chat demo). but it’s constructor looks like this:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rosherove/WindowClipping_1HG2PA.png"&gt;&lt;img title="WindowClipping" style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="145" alt="WindowClipping" src="http://weblogs.asp.net/blogs/rosherove/WindowClipping_thumb_qfKb+Q.png" width="408" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;What if we wanted to control during our test whether the page is enabled or disabled? &lt;/p&gt;  &lt;p&gt;Here’s one way to do it using Isolator:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;In your test project add two references under the .NET tab: “Typemock Isolator” and “Typemock ArrangeActAssert”&lt;/li&gt;    &lt;li&gt;Write the following test:&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rosherove/WindowClipping%20(2)_RPaiTA.png"&gt;&lt;img title="WindowClipping (2)" style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="194" alt="WindowClipping (2)" src="http://weblogs.asp.net/blogs/rosherove/WindowClipping%20(2)_thumb_4mlE+A.png" width="451" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Using Isolate.WhenCalled() we are able to circumvent any method (static or not) to return whatever we want, or throw an exception.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Here’s a more interesting case. Let’s say we have a method that modifies the current page and shows some html to the user in a span tag:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rosherove/WindowClipping%20(3)_mjd/2g.png"&gt;&lt;img title="WindowClipping (3)" style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="112" alt="WindowClipping (3)" src="http://weblogs.asp.net/blogs/rosherove/WindowClipping%20(3)_thumb_Bf9WqQ.png" width="581" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;here is one way to write a test that makes sure that the right text is set into the message element in the page, without needing to have a real page present:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rosherove/WindowClipping%20(4)_7L0kSA.png"&gt;&lt;img title="WindowClipping (4)" style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="377" alt="WindowClipping (4)" src="http://weblogs.asp.net/blogs/rosherove/WindowClipping%20(4)_thumb_elBN9g.png" width="626" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;There are several things to note here:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;HtmlElement is &lt;strong&gt;Sealed&lt;/strong&gt; has an &lt;strong&gt;internal constructor&lt;/strong&gt;, but we can still create a fake instance of it using Isolator. None of the other frameworks can do this.&lt;/li&gt;    &lt;li&gt;We are returning a fake object from a &lt;strong&gt;method call chain &lt;/strong&gt;(HtmlPage.Document.GetElementById ) without needing to create a separate stub for &lt;strong&gt;document&lt;/strong&gt;. None of the other frameworks can do this (especially since it is based on a &lt;strong&gt;static &lt;/strong&gt;method call to begin with)&lt;/li&gt;    &lt;li&gt;We assert in the end that the method was indeed called with the correct arguments without needing to change a single piece of code. Granted, I wouldn’t write code like this (I like decoupling!) but sometimes you just don’t have the ability to change existing code.&lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;If you are developing an open source silverlight project, it is important to note that there is a free full version of isolator for open source projects with full functionality.&lt;/p&gt;  &lt;p&gt;These are just the beginning of my journey into silverlight unit testing. I’m looking for good code examples that you might want to test, with various dependencies that need breaking. your comments are appreciated.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6808150" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rosherove/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Art+Of+Unit+Testing/default.aspx">Art Of Unit Testing</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Typemock/default.aspx">Typemock</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Isolator Feature Focus: Duck Typing and Isolate.Swap</title><link>http://weblogs.asp.net/rosherove/archive/2008/11/02/isolator-feature-focus-duck-typing-and-isolate-swap.aspx</link><pubDate>Sun, 02 Nov 2008 12:25:00 GMT</pubDate><guid isPermaLink="false">c06e2b9d-981a-45b4-a55f-ab0d8bbfdc1c:6716046</guid><dc:creator>RoyOsherove</dc:creator><slash:comments>5</slash:comments><wfw:commentRss>http://weblogs.asp.net/rosherove/rsscomments.aspx?PostID=6716046</wfw:commentRss><comments>http://weblogs.asp.net/rosherove/archive/2008/11/02/isolator-feature-focus-duck-typing-and-isolate-swap.aspx#comments</comments><description>&lt;p&gt;&lt;a href="http://www.typemock.com/commdl.php"&gt;Typemock Isolator 5.1.1&lt;/a&gt; has been released, and this release brings with it some awesome (seriously) features that are unique fro any other framework I've seen.&lt;/p&gt;  &lt;p&gt;a &lt;a href="http://blog.typemock.com/2008/10/typemock-isolator-511-is-out.html"&gt;good overview of features can be found here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;The Isolator Swap feature &lt;/strong&gt;allows swapping calls between real and fake objects (kind like redirects) so that any relevant calls made against the real object will be redirected and invoked on the fake object. &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Here's how you use it:&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://weblogs.asp.net/blogs/rosherove/WindowsLiveWriter/IsolatorFeatureFocusDuckTypingandIs.Swap_CC8A/image_2.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="133" alt="image" src="http://weblogs.asp.net/blogs/rosherove/WindowsLiveWriter/IsolatorFeatureFocusDuckTypingandIs.Swap_CC8A/image_thumb.png" width="340" border="0" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Unlike doing a standard &amp;quot;WhenCalled()&amp;quot; on some object method and telling what its custom behavior will be, &amp;quot;Swapping&amp;quot;&amp;#160; objects redirects &lt;strong&gt;all &lt;/strong&gt;relevant calls(I'll explain what &amp;quot;relevant&amp;quot; means in a second) to the fake object which you have created.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;strong&gt;Duck Typing Awesomeness&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Another cool thing about it is that &amp;quot;Duck&amp;quot; and &amp;quot;Dog&amp;quot; don't have to have a shared interface or base class. The &amp;quot;Swap&amp;quot; feature will redirect a method call if it exists on the &amp;quot;fake&amp;quot; object, but if it does not, it will invoke the original object. This is one interpretation of what's called &amp;quot;&lt;a href="http://haacked.com/archive/2007/08/19/why-duck-typing-matters-to-c-developers.aspx"&gt;Duck Typing&lt;/a&gt;&amp;quot;.&lt;/p&gt;  &lt;p&gt;The &amp;quot;CallsOn&amp;quot; and &amp;quot;WithCallsTo&amp;quot; methods take an object type, so you can send in anything you want.&amp;#160; if a method on the fake object matches the signature and name of a called method on the real object, the fake method will be invoked.&lt;/p&gt;&lt;img src="http://weblogs.asp.net/aggbug.aspx?PostID=6716046" width="1" height="1"&gt;</description><category domain="http://weblogs.asp.net/rosherove/archive/tags/Unit+Testing/default.aspx">Unit Testing</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/.NET/default.aspx">.NET</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Agile/default.aspx">Agile</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Art+Of+Unit+Testing/default.aspx">Art Of Unit Testing</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/Typemock/default.aspx">Typemock</category><category domain="http://weblogs.asp.net/rosherove/archive/tags/FeatureFocus/default.aspx">FeatureFocus</category></item></channel></rss>
