<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.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>One step past Assert.Throws&amp;lt;&amp;gt;</title><link>http://blogs.msdn.com/agilemonkey/archive/2008/07/29/one-step-past-assert-throws.aspx</link><description>If you’re not using xUnit (and you should be), at least consider adopting the practices they have for dealing with exceptions in unit tests. From the very first release, they moved us from this: [ExpectedException(typeof(InvalidOperationException))] public</description><dc:language>en-CA</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>re: One step past Assert.Throws&lt;&gt;</title><link>http://blogs.msdn.com/agilemonkey/archive/2008/07/29/one-step-past-assert-throws.aspx#8789376</link><pubDate>Tue, 29 Jul 2008 19:59:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8789376</guid><dc:creator>kfarmer</dc:creator><description>&lt;p&gt;I prefer the first. &amp;nbsp;It captures, visually, the scope of the exceptional case. &amp;nbsp;Further, if the case is progressive -- I verify that I receive an exception and move on to other things -- then the first approach makes this clearer.&lt;/p&gt;
&lt;p&gt;Especially if a test fails, in which case you'll enter the debugger at the failing case, rather than at the assertion for that case. &amp;nbsp;When a test fails, I want to be pointed as close as possible to the part that failed, in which case keeping all the actions ahead of all the assertions is precisely what you don't want.&lt;/p&gt;
&lt;p&gt;Now, what the second could give you is some flexibility in being able to define assertion extensions on type: Assert.SomeTest(this Type, args), but I'd probably want, instead:&lt;/p&gt;
&lt;p&gt;Assert.Exception(action)&lt;/p&gt;
&lt;p&gt;.IsType&amp;lt;T&amp;gt;()&lt;/p&gt;
&lt;p&gt;.HasMessage(Errors.FooError(args)); // important! &amp;nbsp;How do you know you got the right one, and how do you know it's been localized?&lt;/p&gt;
&lt;p&gt;.. But I can get that with&lt;/p&gt;
&lt;p&gt;Assert.ExpectedException(Exception, Action, Comparer&amp;lt;Exception&amp;gt;)&lt;/p&gt;</description></item><item><title>re: One step past Assert.Throws&lt;&gt;</title><link>http://blogs.msdn.com/agilemonkey/archive/2008/07/29/one-step-past-assert-throws.aspx#8789981</link><pubDate>Wed, 30 Jul 2008 00:31:00 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8789981</guid><dc:creator>Stephen</dc:creator><description>&lt;p&gt;Crotch operator... AHHHH I See it now :)&lt;/p&gt;</description></item></channel></rss>