Skip to content
Browse files

recovering some older blog posts

  • Loading branch information...
aaronpowell committed Oct 22, 2017
1 parent 29c5c1d commit 4113ab48313ea43fd9998cedabaf2f6893bf7816
Showing with 584 additions and 0 deletions.
  1. +16 −0 src/content/posts/
  2. +15 −0 src/content/posts/
  3. +26 −0 src/content/posts/
  4. +21 −0 src/content/posts/
  5. +52 −0 src/content/posts/
  6. +16 −0 src/content/posts/2009-03-10-i-still-don'
  7. +20 −0 src/content/posts/
  8. +21 −0 src/content/posts/
  9. +16 −0 src/content/posts/
  10. +14 −0 src/content/posts/
  11. +70 −0 src/content/posts/
  12. +17 −0 src/content/posts/
  13. +15 −0 src/content/posts/
  14. +27 −0 src/content/posts/
  15. +20 −0 src/content/posts/
  16. +22 −0 src/content/posts/
  17. +12 −0 src/content/posts/2009-05-17-linq-to-umbraco-update-(number-2).md
  18. +13 −0 src/content/posts/2009-05-24-windows-7-virtual-xp-and-i'
  19. +16 −0 src/content/posts/
  20. +37 −0 src/content/posts/
  21. +66 −0 src/content/posts/
  22. +36 −0 src/content/posts/
  23. +16 −0 ...t/posts/
@@ -0,0 +1,16 @@
title = "Typemock AAA - Faking the same method with different parameters"
date = "2009-02-25T20:36:49.0000000Z"
tags = ["Unit Testing","Umbraco","Typemock"]
draft = false

<p>As I stated in my <a href="" target="_blank">last post</a> (oh so 5 minutes ago! :P) I'm working on a new project for the Umbraco team, one thing I'm really focusing hard on with LINQ to Umbraco is Test Driven Development (TDD), and with that I'm using <a href="" target="_blank">Typemock</a> as my mocking framework (since I scored a <a href="/{localLink:1291}" target="_blank" title="Mocking with SharePoint">free license</a> I thought I should use it).</p>
<p>The Arrange, Act, Assert (AAA) is really sweet, but it does have a problem, it doesn't support mocking a method call with different parameters. I can't call the same method 3 times and have a different output depending on what was passed in.</p>
<p>Makes for a bit of a problem when you want to test conditionals against your mock. <a href="" target="_blank">I have requested the feature</a>, but for the time being I found a nice little work-around, <strong>Extension Methods</strong>!</p>
<p>So I'm mocking the <span class="const">IRecordsReader</span> from the Umbraco DataLayer, and I want to have something different returned depending on the parameter of the GetString method, so I created extensions like this:</p>
<pre><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">string</span> GetName(<span class="keyword">this</span> <span class="const">IRecordsReader</span> reader){<br /> <span class="keyword">return</span> reader.GetString(<span class="string">"Name"</span>);<br />}<br /></pre>
<p>Now I can easily do this:</p>
<pre><span class="const">Isolate</span>.WhenCalled(() =&gt; fakeReader.GetName()).WillReturn(<span class="string">"Name"</span>);<br /><span class="const">Isolate</span>.WhenCalled(() =&gt; fakeReader.GetString(<span class="string">"SomethingElse"</span>)).WillReturn(<span class="string">"Not Name"</span>);<br /><br />// do something with fakeReader<br /><br /><span class="const">Isolate</span>.Verify.WasCalledWithExactArguments(() =&gt; fakeReader.GetName());<br /><span class="const">Isolate</span>.Verify.WasCalledWithExactArguments(() =&gt; fakeReader.GetString(<span class="string">"SomethingElse"</span>));<br /></pre>
<p>This obviously isn't the best way to do it, does mean that you have to then use extension methods when you are writing the code to use it.<br />But that's not really a problem for me at the moment, I'm doing a lot of the same data reading from the IRecordsReader so I can easily do the extension method.</p>
<p>Now if they will just add the support like Rhino Mocks has then it'll be sweet!</p>
@@ -0,0 +1,15 @@
title = "UIL v1.1 release, and some sadness"
date = "2009-02-25T20:14:20.0000000Z"
tags = ["Umbraco","Umbraco.InteractionLayer"]
draft = false

<p>Well today I have produced the latest version of the UIL, v1.1, which can be downloaded here: <a href="" target="_blank"></a>. This version addresses a problem found with the <strong>IsDirty</strong> state when opening existing documents.<br />During a development implementation of it there it was noticed that when you opened existing documents the IsDirty always returned true.</p>
<p>This is now fixed, and I also addressed another problem which was realised. It was actually a design limitation, not a bug (per-say). I had the UIL relying on the ID's of the DocTypes <strong>at time of generation</strong>, this posed a problem when using the UIL on existing websites. When you tried to deploy the DocTypes into a new environment using Umbraco Packaging (or manually creating them), a <strong>new ID</strong> would be generated! This posed a big problem. Instead I have change it so the UIL relies on the <strong>alias at time of generation</strong>, which isn't 100% unique, but it's <em>unique enough</em> ;).</p>
<p>But there is also a bit of sadness in this post, as this post signals the final installment of UIL being under active development (although I use the term active loosely :P). I will no longer be actively adding features to the UIL, unfortunately I no longer have the time to dedicate to the project and implement the features which I had intended to implement. I will <em>try</em> and implement fixes for any bugs which people find, but really I don't have enough time to work on anything new for the UIL.</p>
<p>But it's not all sad, there is a good reason which I no longer have the time to dedicate to the UIL, it is because I have taken on a bigger project. After speaking with Niels and the other guys who make up the Umbraco project I've been asked to develop a proper LINQ to Umbraco implementation. That's right, I'm currently working to produce what the UIL was originally going to become, a LINQ provider for Umbraco.</p>
<p>I'm going to keep some of the details secret, but I'll just say that at the moment the UIL isn't going to be <em>completely</em> replaced by LINQ to Umbraco, rather it's going to be <em>suplimented </em>by it. Where UIL is all about how to interact with <strong>Documents</strong> and <strong>Document creation</strong> LINQ to Umbraco is going to be all about interacting with <strong>published nodes</strong> and the Umbraco node cache.</p>
<p>So be on the lookout for some really interesting posts in the coming weeks/ months in which I'll provide more details on LINQ to Umbraco, or feel free to watch the progress of the of the code on Codeplex..</p>
<p>So sad times, with happy times.</p>
@@ -0,0 +1,26 @@
title = "An observation on browsers"
date = "2009-03-01T17:09:38.0000000Z"
tags = ["Random Junk"]
draft = false

<p>I've been a big fan of the <a href="" target="_blank">Opera</a> web browser for a number of years, I've used it since it's v4 days. I remember it being an ad-supported browser and I remember when it became free (that was a great day!). I remember it being a very innovative browser (and it still is) with this such as:</p>
<li>Tabbed browsing</li>
<li>Mouse gestures</li>
<li>Speed Dial</li>
<li>Session Management</li>
<p>It's served me well for a long time, on every platform from Windows to Linux to Mac OS X, and even mobile devices.</p>
<p>But this weekend things haven't been so good, Opera started crashing on me, constantly, even when the browser was in the background in an idle state.</p>
<p>So I've reverted back to using Safari. I <em>could </em>use Firefox, but I've never been a fan of Firefox as a daily browser. I find it a great web dev tool thanks to the plugin engine, but it's always felt cumbersome as a daily browser. It is heavy and slow to start up, and it's never had a good feel to it as a daily browser.</p>
<p>But Safari is starting to shit me. Since that Safari 4.0 beta came out this week I thought it'd be an idea to have a crack at it, see how it goes. Well I can tell you, it's currently <strong>not</strong>&nbsp;going.<br />First off, I had to install a security patch before I could install the browser. Ok, fine, I hadn't been keeping up-to-date with the paths, but c'mon, it's a single patch which had only just been released!<br />So I installed the patch, which required a reboot, and then re-ran the Safari 4 installer.</p>
<p>And that didn't exactly go well, to install Safari 4 on a latest-patched OS X 10.5 install you need <strong>107Mb of hard drive space</strong>! WTF?! It's just a browser! People blame Microsoft software for being bloated, but I'm pretty sure that the IE 8 beta isn't that big!<br />The next hurdle is that it requires me to <strong>reboot to install</strong>. Again, WTF?! IT'S JUST A BROWSER!</p>
<p>This is something that's really starting to piss me off about OS X, it's worse than Vista when it comes to reboot-on-install, and worse off is that you have to be rebooting for the install to take place. Unlike Vista which you can install and it'll finish the install during the reboot OS X requires you to do the complete reboot while installing.<br />BUT WHY DO I NEED TO REBOOT FOR A BROWSER!? (I've got another gripe about having to reboot to install the new version of Quicktime, why the fuck do I have to reboot to install a media player, but that's a rant for another day)</p>
<p>So I'm sticking with Safari 3 for now, and I'm starting to realise just how limiting it is as a browser, compared to the others of its generation.<br />Lets first compare it with IE 7, the Microsoft browser of the same generation. By-and-by they are as good as each other. But there's one glaring feature that Safari lacks compared to IE is session management. It's a common feature across current generation browsers, remembering what you were doing when you exited so when you next pick it up you are where you were previously.<br />But I can't for the life of me work out where I can turn it on.</p>
<p>Another feature I can't seem to work out is how to have images shown at the full size, not scaling it to the window by default. It's a simple to turn off in IE, but so far it's eluding me in Safari.</p>
<p>Lastly I'm finding that Safari always wants to download files where it wants, I never get asked. Again, a feature of all current browsers, except Safari.</p>
<p>Overall what I've noticed with Safari and IE alike, is that OS-related browsers are well behind the curve. With a release cycle like Opera and Firefox not being tied to that of an OS they can push them out a lot faster, leaving the others behind.</p>
<p>Safari is an Ok browser, like IE is an Ok browser. But I wish I could get Opera back, and I wish that Umbraco would work from it :P&nbsp;</p>
@@ -0,0 +1,21 @@
title = "A nifty Typemock extension"
date = "2009-03-03T22:49:47.0000000Z"
tags = ["Unit Testing","Typemock"]
draft = false

<p>Using AAA with Typemock there's a bit of a problem if you want to repeat the returned value a number of times before then doing something different. It's very useful if you are accessing a mocked object within a loop and want to know the number of loop execution.</p>
<p>So I've put together a simple little Typemock extension (but I'm sure it'd adaptable for any mock framework supporting AAA):</p>
<pre><span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">void</span> WillReturnRepeat&lt;TReturn&gt;(<span class="keyword">this</span> <span class="const">IPublicNonVoidMethodHandler</span> ret, TReturn value, <span class="keyword">int</span> numberOfReturns)
<span class="keyword">for</span> (<span class="keyword">var</span> i = 0; i &lt; numberOfReturns; i++)
<p>You then just use it like this:</p>
<pre><span class="const">Isolate</span>.WhenCalled(() =&gt; mockObject.SomeMethod()).WillReturnRepeat(true, 3);
<span class="const">Isolate</span>.WhenCalled(() =&gt; mockObject.SomeMethod()).CallOriginal();
<p>So the mock will return <strong>true</strong>&nbsp;3 times and it will do the original call (for the purpose of this demo we'll assume it would return <strong>false</strong>).</p>
<p>Anyone else got some nifty Typemock extensions? &nbsp;</p>
@@ -0,0 +1,52 @@
title = "A nifty Typemock extension on steroids"
date = "2009-03-06T13:04:47.0000000Z"
tags = ["Unit Testing","Typemock"]
draft = false

<p>So in my last post I showed a nifty Typemock extension for doing repetition within Typemock's AAA syntax on the WhenCalled method. When I wrote that extension it was only done in a rush and it had 1 flaw, you couldn't do method chaining to do the n+1 action, you had to do it on a separate line.</p>
<p>Well I spent another 5 minutes on it and added this feature (plus a repeat on CallOriginal). Here's the updated extension set:</p>
<pre> <span class="keyword">public</span> <span class="keyword">static</span> <span class="keyword">class</span> Extensions
<span class="keyword">public static</span> <span class="const">ActionRepeater</span>&lt;TReturn&gt; WillReturnRepeat&lt;TReturn&gt;(this <span class="const">IPublicNonVoidMethodHandler</span>&lt;TReturn&gt; ret, TReturn value, <span class="keyword">int</span> numberOfReturns)
<span class="keyword">for</span> (<span class="keyword">var</span> i = 0; i &lt; numberOfReturns; i++)

<span class="keyword">return new</span> <span class="const">ActionRepeater</span>&lt;TReturn&gt;(ret);

<span class="keyword">public static</span> <span class="const">ActionRepeater</span>&lt;TReturn&gt; CallOriginalRepeat&lt;TReturn&gt;(this <span class="const">IPublicNonVoidMethodHandler</span>&lt;TReturn&gt; ret, <span class="keyword">int</span> numberOfReturns)
<span class="keyword">for</span> (<span class="keyword">var</span> i = 0; i &lt; numberOfReturns; i++)

<span class="keyword">return new</span> <span class="const">ActionRepeater</span>&lt;TReturn&gt;(ret);

<span class="keyword">public class</span> <span class="const">ActionRepeater</span>&lt;TReturn&gt;
<span class="keyword">private</span> <span class="const">IPublicNonVoidMethodHandler</span>&lt;TReturn&gt; _actionRepeater;
<span class="keyword">public</span> <span class="const">ActionRepeater</span>&lt;TReturn&gt;(<span class="const">IPublicNonVoidMethodHandler</span>&lt;TReturn&gt; actionRepeater)
_actionRepeater = actionRepeater;
<span class="keyword">public</span> <span class="const">IPublicNonVoidMethodHandler</span>&lt;TReturn&gt; AndThen()
return _actionRepeater;
<p>I'll admit that I have made it a touch verbose to use, but I think it's better to convey what is happening to other people reading the tests (it's a lot like Rhino Mocks in verboseness I guess). So to use it now all you need to do is:</p>
<pre><span class="const">Isolate</span>.WhenCalled(() =&gt; someMock.SomeMethod()).WillReturnRepeat(<span class="keyword">true</span>, 3).AndThen().CallOriginal();
//or, chained repeats!
<span class="const">Isolate</span>.WhenCalled(() =&gt; someMock.SomeOtherMethod()).WillReturnRepeat(<span class="string">"Hello World"</span>, 2).AndThen().WilLReturnRepeat(<span class="keyword">"Good-bye World"</span>, 2).AndThen().CallOriginal();
<p>Makes for some really crazy mocks ;)</p>
<p>PS: You can use the <em>Repeat</em>&nbsp;extensions with a repeat number of 1 if you want just method chaining too:</p>
<pre><span class="const">Isolate</span>.WhenCalled(() =&gt; someMock.SomeMethod()).WillReturnRepeat(<span class="keyword">true</span>, 1).CallOriginalRepeat(1).ReturnRecursiveFakes();</pre>
@@ -0,0 +1,16 @@
title = "I still don't get Twitter"
date = "2009-03-10T19:23:57.0000000Z"
tags = ["Random Junk"]
draft = false

<p>So Karl posted today (well, tomorrow at 2.29am or something, yeah <strong>my</strong> blog isn't the only one who's dates are freaky!) asking <a href="" target="_blank">what value Twitter adds</a>.</p>
<p>As I <a href="/{localLink:1354}" target="_blank" title="Twitterific">recently posted</a> I have a twitter account and I don't really get the point either.</p>
<p>But I must confess, I'm getting more into it, well, into it but still not getting its point.</p>
<p>Originally when I got onto as I was trying to get a hold of Niels, he was away from his email at the time and I knew he was still checking that :P</p>
<p>Now I do use it a bit more, mainly I use it still to follow Umbraco stuff, but I also follow some others. I started following <a href="" target="_blank">Elijah Manor</a> who seems to do nothing but find other interesting blogs on the topic of AJAX, jQuery, etc. I've had a lot of interesting stuff come across his feed.</p>
<p>I also started following <a href="" target="_blank">Paul Stovell</a> since his blog went down and he's tool <span>lazy</span>busy to fix it.</p>
<p>I <strong>definately</strong> don't get the point of if for the <a href="" target="_blank">I'm Pooping</a> tweets :P</p>
<p>Interesting side-note, my 4th largest source of traffic to my blog is Twitter!</p>
@@ -0,0 +1,20 @@
title = "A LINQ observation"
date = "2009-03-19T12:44:44.0000000Z"
tags = ["LINQ","LINQ to SQL","Umbraco","LINQ to Umbraco"]
draft = false

<p>Well I'm making good headway with LINQ to Umbraco, in the next few days I'll be doing a very interesting check in (which I'll also blog here about). My tweet-peeps already have an idea of what it entails, but there's a bit of a problem with it still which I want to address before the commit.</p>
<p>And that problem has lead to an observation I made about LINQ, well, about <em>Expression</em>-based LINQ (ie - something implementing IQueryable, so LINQ to SQL, or LINQ to Umbraco, etc).</p>
<p>I'll use LINQ to SQL for the examples as it's more accessible to everyone.</p>
<p>Take this LINQ statement (where <strong>ctx</strong> is an instance of my DataContext):</p>
<p>var items = ctx.Items;</p>
<p>That statement returns an object of Table&lt;Item&gt;, which implements IQueryable&lt;T&gt;, IEnumerable&lt;T&gt; (and a bunch of others that are not important for this instructional). So it's not executed yet, no DB query has occured, etc. Now lets take this LINQ statement:</p>
<p>var items2 = from item in ctx.Items select item;</p>
<p>This time I get a result of IQueryable&lt;Item&gt;, which implements IQueryable&lt;T&gt; (duh!) and IEnumerable&lt;T&gt; (and again, a bunch of others).</p>
<p>Both of these results have a non-public property called Expression. This reperesents the expression tree which is being used to produce our collection. But here's the interesting part,<strong> they are not the same</strong>. That's right, although you're getting back <em>basically</em> the same result, the expression used to produce that result is really quite different.<br />This is due to the way the compiler translates the query syntax of LINQ into a lambda syntax. In reality the 2nd example is equal to this:</p>
<p>var items2 = ctx.Items.Select(item =&gt; item);</p>
<p>But is this really a problem, what difference does it make? In the original examples you actually get back the same data every time. You'll have <em>slightly</em> less overhead by using the access of Table&lt;T&gt; rather than IQueryable&lt;T&gt;, due to the fact that you're not doing a redundant call to Select. But in reality you would not notice the call.</p>
<p>This has caused a problem for me as my direct-access lambda syntax fails my current unit test, where as the query syntax passes. Now to solve that problem! ;)</p>
Oops, something went wrong.

0 comments on commit 4113ab4

Please sign in to comment.
You can’t perform that action at this time.