just ram

stuff I should remember

Books + Head First C# + Lab 1 Solution

I’ve been reading through the new Head First book Head First C# which appeared on Safari just before Christmas. I’ve been a fan of the Head Fist books ever since reading their best selling Head First Design Patterns book. This particular book is aimed at beginners / hobbyists so I’m not exactly the target audience but hey it covers C# 3 so its got to be worth at least a skim.

I was pleased to see they’ve added a new feature to the head first series namely lab sections. There are 3 lab sections in the book which are basically specifications for mini games, the idea being the reader creates the games using their newly acquired C# skills. I though this was a great idea and having a lot of spare time in front of my laptop over the Christmas (due to a very sore ankle) I did the first of the labs “A day at the races”.

I used the lab as an exercise in Behaviour Driven Development (BDD) which I’d recently read about here and here. I also got to try out a Test Data Builder I’d read about here. Now I’m not convinced I hit the nail on the head with the BDD as my solution wasn’t created in a test behaviour first manor. This was mainly due to the fact the book provides you with the shell of a solution to keep things nice and simple for beginners. Never the less it was a good fun doing the lab it’s a great way to try out new techniques.

All in all the BDD experience was pretty good not sure about the code duplication in the context setup but you got to love the way the descriptive contexts and method names combine to read like a sentence:

Also the Test Data Builder is a really flexible way to create test data using a fluent interface which again is really easy to read:

myGuy = new GuyBuilder().WithName("Joe").AndCash(50).Build();

You can download the solution here.

Castle + Using the Trunk + My registry entries

When I build from the trunk I usually follow the instructions found here:

http://using.castleproject.org/display/CASTLE/Using+the+Trunk

My source location is slightly different from the instructions so I have to hand edit the registry entries listed at the end of the page. So to save me doing that again here they are:

Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Castle] "vs8templatelocation"="C:\\source\\Castle\\Tools\\VSNetWizards\\CastleTemplates\\VS8" [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v2.0.50727\AssemblyFoldersEx\castle] @="C:\\source\\Castle\\build\\net-2.0\\debug"

Monaco F1 Grand Prix 2007

I was lucky enough to be at the Monaco F1 Grand Prix this year after a friend (John “Diddy” Donaldson) won a trip aboard a luxury yacht for the weekend. After nail biting coin toss I was invited along to literally the trip of a life time. So here are the photos, videos and links:

PHOTOS http://www.flickr.com/photos/justinpics/sets/72157600282065312/ http://www.flickr.com/photos/justinpics/sets/72157600286256602/

VIDEOS http://www.youtube.com/view_play_list?p=B39BC24DE3FD196F

LINKS - In case you want to hire the yacht http://www.luxuryachts.net/yacht.asp?y=starofthesea

http://www.cnconnect.com/charter/yachtdetail.aspx?id=3929

http://www.csoyachts.com/view_yacht.php?ref_bat=0327018

The only downside of the trip was the day after the race when depression sets in as you realise your not really a millionaire!

Monorail + NVelocity + How to find out if your in the first item of a foreach loop?

A colleague needed to add a button to the first row of a table but how do you do this in a foreach loop?

NVelocity has a property called $velocityCount which you can check within the foreach loop:

<span class="kwrd"><</span><span class="html">table</span><span class="kwrd">></span>
#foreach($detail in $details)
  <span class="kwrd"><</span><span class="html">tr</span><span class="kwrd">></span>
    <span class="kwrd"><</span><span class="html">td</span><span class="kwrd">></span>
      $detail.ShortText)
      #if($velocityCount == 1) First Row! #end
    <span class="kwrd"></</span><span class="html">td</span><span class="kwrd">></span>
  <span class="kwrd"></</span><span class="html">tr</span><span class="kwrd">></span>
#end
<span class="kwrd"></</span><span class="html">table</span><span class="kwrd">></span>

SAP Enterprise Portal + Automated Functional Testing - Part 7 of …

In anticipation of posting about a new topic I’m going to wrap up my Watir Automated testing posts with a few more top tips.

TOP TIP - How do I run a single test?

So you have lots of tests in your test suite but only want to run one? No need to create an ad-hoc test case, simply pass in the –name parameter when running the test:

ruby test_mytestcase.rb --name test_just_this_method

TOP TIP - How do I run the test in background mode?

Running the test so you can see what is going on in the browser is sometimes useful but most of the time you’ll want to run the tests in the background and just see the results. This is easily done by passing the -b parameter on the command line:

ruby test_mytestcase.rb -b

TOP TIP - Helper methods

I have a couple of helper methods which I use in most of my test cases: ` def should_find(find_me) assert(@ie.contains_text(find_me), “\n\n\nText not found: #{find_me}\n\n\n”) end

def should_not_find(find_me) assert_nil(@ie.contains_text(find_me), “\n\n\nFound text which should not be present: #{find_me}\n\n\n”) end ` No clever code here it just means I can write tests which are easier to read: ` should_not_find(“Portal Runtime Error”) should_find(“Success”) ` FIN Well I’m running out of content about testing as you can probably tell! So I guess that’s a wrap. I’ll no doubt re-visit automated testing again at some point but for now that’s my lot.

NEXT TIME I’ve been working on creating web services for Enterprise Portal and calling those web services from Microsoft .Net. I’ve taken lots of notes, so expect a series of EP web services posts real soon.

SAP Portal how do I reference a Javascript file?

Easy when you know how

request = (IPortalComponentRequest)this.getRequest();
response = (IPortalComponentResponse)this.getResponse();
IResource jsResource = request.getResource(IResource.SCRIPT, “scripts/myscript.js”);
response.addResource(jsResource);

Ruby unit testing - run only one test

If you don’t wish to run all the unit tests in your test case you can tell ruby to run only one by passing in the name of the test:

  ruby test_mytestcase.rb --name test_just_this_method