<?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>Strong as an Ox &#187; c#</title>
	<atom:link href="http://www.strongasanox.co.uk/category/c/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.strongasanox.co.uk</link>
	<description>Ian Oxley - ASP.NET, PHP, JavaScript and Web Applications</description>
	<lastBuildDate>Tue, 24 Aug 2010 22:54:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>How To Reset Your SubSonic 3 ActiveRecord Test Repository For Each Unit Test</title>
		<link>http://www.strongasanox.co.uk/2009/09/04/how-to-reset-your-subsonic-3-activerecord-test-repository-for-each-unit-test/</link>
		<comments>http://www.strongasanox.co.uk/2009/09/04/how-to-reset-your-subsonic-3-activerecord-test-repository-for-each-unit-test/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 13:09:38 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[subsonic]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://www.strongasanox.co.uk/?p=171</guid>
		<description><![CDATA[When writing unit tests with SubSonic&#8217;s new built-in testing for ActiveRecord don&#8217;t forget that each time you call the Setup() method on your ActiveRecord object it adds records to any that have already been created. For example: [Test] public void Foo_Bar() { Foo.Setup(10); Assert.AreEqual(10, Foo.All().Count()); } [Test] public void Bar_Foo() { Foo.Setup(10); // This will [...]]]></description>
			<content:encoded><![CDATA[<p>When writing unit tests with <a href="http://subsonicproject.com/docs/Using_ActiveRecord#Testing">SubSonic&#8217;s new built-in testing for ActiveRecord</a> don&#8217;t forget that each time you call the <strong>Setup()</strong> method on your ActiveRecord object it adds records to any that have already been created. For example:</p>
<pre>[Test]
public void Foo_Bar() {
    Foo.Setup(10);
    Assert.AreEqual(10, Foo.All().Count());
}

[Test]
public void Bar_Foo() {
    Foo.Setup(10);

    // This will fail: Foo.All().Count() will return 20
    Assert.AreEqual(10, Foo.All().Count());
}</pre>
<p>To reset your test repositories you will need to call the <strong>ResetTestRepo()</strong> method prior to each test, which can be accomplished easily enough by adding the method call to your test&#8217;s <strong>[SetUp]</strong> method:</p>
<pre>[SetUp]
public void SetUp() {
    Foo.ResetTestRepo();
}

[Test]
public void Foo_Bar() {
    Foo.Setup(10);
    Assert.AreEqual(10, Foo.All().Count());
}

[Test]
public void Bar_Foo() {
    Foo.Setup(10);

    // Now Foo.All().Count() will return 10 and the test will pass
    Assert.AreEqual(10, Foo.All().Count());
}</pre>
<p>Hopefully this will save you a bit of time, as well as head scratching :p</p>
]]></content:encoded>
			<wfw:commentRss>http://www.strongasanox.co.uk/2009/09/04/how-to-reset-your-subsonic-3-activerecord-test-repository-for-each-unit-test/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# String Extension Methods</title>
		<link>http://www.strongasanox.co.uk/2009/07/20/c-sharp-string-extension-methods/</link>
		<comments>http://www.strongasanox.co.uk/2009/07/20/c-sharp-string-extension-methods/#comments</comments>
		<pubDate>Mon, 20 Jul 2009 20:57:36 +0000</pubDate>
		<dc:creator>Ian</dc:creator>
				<category><![CDATA[asp.net]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://www.strongasanox.co.uk/?p=115</guid>
		<description><![CDATA[There are quite a few instances where string operations in C# seem slightly verbose. So, I had a play around with extension methods the other day to see if I could come up with some alternate ways of doing some pretty standard operations but with a touch more syntactic sugar sprinkled on the top. For [...]]]></description>
			<content:encoded><![CDATA[<p>There are quite a few instances where string operations in C# seem slightly verbose. So, I had a play around with extension methods the other day to see if I could come up with some alternate ways of doing some pretty standard operations but with a touch more syntactic sugar sprinkled on the top.</p>
<p>For example, rather than using <code>string.IsNullOrEmpty</code> it makes much more sense to me to call <code>IsNullOrEmpty</code> on the string you want to check instead:</p>
<pre>// Checking for a null or empty string in C#
if (string.IsNullOrEmpty(foo)) {
    ...
}

// versus
if (foo.IsNullOrEmpty()) {
    ...
}</pre>
<p>Also, I thought it would be nicer if you could call some of the static <code>Regex</code> methods directly on string objects:</p>
<pre>// Instead of this
if (Regex.IsMatch(foo, @"[a-zA-Z]+")) {
    ...
}

// You could just do this
if (foo.IsMatch(@"[a-zA-Z]+")) {
    ...
}</pre>
<p>I have created a gist of these methods, plus a few others:</p>
<p><a href="http://gist.github.com/111696">http://gist.github.com/111696</a></p>
<p>Are there any other string operations that you think should be included? If you have any suggestions, etc. please be sure to comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.strongasanox.co.uk/2009/07/20/c-sharp-string-extension-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
