Tuesday, November 25, 2008

Beach Series Race 4

Last night was race 4 in the beach series. It was the high tide course again, so there was no way I was going to beat last weeks time. However, I did beat my previous time on the high tide course by a little over 20 seconds. So that was good.

This week's start was about 30 minutes after the peak of the high tide, so hopefully next week will be just after the lowest tide again. Definitely need to get some speed work in this week then. Easy recovery run today. The weather was great out there.

Week Time Place Notes
2 23:21 22nd High tide course - loose sand, 3 laps.
3 20:56 28th Low tide course - perfect weather.
4 22:52 28th High tide course - good weather.


Last week I ended up in one of the photos on the website. Swimmers, runners, and kayakers all come running in to the same finish line, so the courses cross each other near the end.

Wednesday, November 19, 2008

Using NMock to Create an IDataReader for Testing Data Access Methods

If you have a simple Data Access class with a method like the one below which you need to test without depending on specific values in the database (and without embarking on a major refactoring expedition).

public decimal GetAvailableBalance(int custNumb)
{
decimal retVal = 0.00M; 
using (SqlConnection sqlConnection = new SqlConnection(_dbConnection))
{
sqlConnection.Open();
using (SqlCommand sqlCommand = sqlConnection.CreateCommand())
{
sqlCommand.CommandType = CommandType.StoredProcedure;
sqlCommand.CommandText = "dbo.GetCustomerBalance";
sqlCommand.Parameters.AddWithValue("CustomerID", custNumb);
using (IDataReader dr = sqlCommand.ExecuteReader())
{
if (dr != null)
{
dr.Read();
retVal = Convert.ToDecimal(dr["AvailableBalance"]);
}
}
}
}
return retVal; 
}


Replace this:
sqlCommand.ExecuteReader()



With This:
public virtual IDataReader GetReader(SqlCommand cmd)
{
return cmd.ExecuteReader(); 
}



Now create a test class that inherits from the Data Access class and override that virtual method. Like so:

[TestFixture]
public class IMTTests : TransactionStore
{
Mockery mocks = new Mockery(); 
IDataReader idr = null; 

public override IDataReader GetReader(SqlCommand cmd)
{
Expect.AtLeastOnce.On(idr).Method("Read").Will(Return.Value(true));
Expect.AtLeastOnce.On(idr).Method("Dispose"); 
return idr; 
}



Now in your test, create your mock DataReader to assign to the private variable and set the specific expectations of your data mapping.

[Test]
public void TestAvailableBalance()
{
idr = (IDataReader)mocks.NewMock(typeof(IDataReader));
Expect.AtLeastOnce.On(idr).Get["AvailableBalance"].Will(Return.Value(42.00M));
Decimal amount = this.GetAvailableBalance(12345);
Assert.AreEqual(42.00M, amount); 
}

Tuesday, November 18, 2008

Beach Series Race 3

Haydn and I ran Race #3 in the North Shore City Beach Series last night.

I came in at 20:56. That's nearly two and a half minutes faster than last week!

I'm very happy with that, especially pulling within 60 seconds of my goal (sub 20:00 by the end of the series). But unfortunately, most of that improvement comes from running on the open hard-packed sand of the low tide course as opposed to dodging through the crowd in the loose sand of the high tide course. So this leap was a free one. The next seconds I shave off are going to take some hard work.

To that end, I've started puttting together a speed training plan. I've found a perfect spot at nearby North Harbour Stadium that has some grassy soccer fields for running sprints and 400ish repeats, some stairs for doing bounding training, and a bike track around the outside of the stadium that measures about 1100 meters.

I took a run over today at lunchtime to give it a try. I pulled some repeat times off McMillan Running's pace calculator based on my 20:56 from last night. That gave me an 1100m repeat time of 4:24 to 4:42 (4:00/k). My race pace worked out to 4:11s, so that seemed reasonable.

I ran two of those at lunchtime to see how they felt. I did the first in 4:17, and the second at 4:29. It was hard, but not gut wrenching, so I think a set of five of those will definitely be one workout a week, probably Friday's. Next I'll give some 400 repeats a try.

My next milestone goal is to beat the Under-13 leader (20:08 last night). I know marathon training has worn away all my speed, but it's still crazy to see little knee-high 10 year olds running barefoot and pulling away from me. ;-)

Week Time Place Notes
2 23:21 22nd High tide course - loose sand, 3 laps.
3 20:56 28th Low tide course - perfect weather.

Saturday, November 15, 2008

Shifting Gears

After this last marathon, I decided to run some shorter races for a while. 5K's to be specific. The North Shore City Beach Series is a 16 week series of races on Tuesday nights at Takapuna beach.

I ran race #2 last week (race 1 was 2 days after the marathon). I ran 23:21, which put me 22nd out of 116 competitors. My best 5k would have put me in 3rd! That might be out of reach without a hell of a lot of work, but I'm hoping to be running under 20 minutes by the end of the series early in the new year. A sub 20 5k would put me in the top 10 as of this week, but I noticed from the results posted for last year that times improve a lot as the weeks go on.

The main thing I have to work on now is speed. I noticed that although I wasn't too winded, I just couldn't pull any more speed out of my legs in this last race.

In any case, I'll be glad to trade 30 kilometer runs for sets of 400 meter repeats. ;-)




WeekTimePlaceNotes
223:2122High tide course - loose sand, 3 laps.


Rangitoto from Takapuna

Monday, November 03, 2008

Auckland Marathon 2008

Auckland Marathon 2008This weekend I ran the Auckland Marathon. This was my 9th marathon, and my 3rd Auckland marathon.

It was also my fastest marathon to date. I ran a 3:38:53, beating my previous record of 3:48:11 by almost 10 minutes! At the same time, I took back the crown from my friend Craig in our little marathon competition.

I think I was probably in the best long distance shape I've ever been in going into this. I was in good shape for my first marathon (and second fastest) in 2002, but I took about 6 weeks off running just before the race with a heel injury (which was annoyingly not even running related - long story). So thanks to Kel, Paul, Staton, Benny, Haydn, and all my training partners for that!

The race conditions were excellent, they'd been forecasting rain, but it never showed up. There was a bit of a headwind on the last 10k or so, and the sun warmed things up a bit in the last hour, but I definitely can't complain about the weather.

Our pace was a bit of a change in plans. My friend Paul and I had been doing long runs at about 5:50-6:00 Km pace. My weekday runs varied anywhere from 5:15 to 6:15. But after seeing Craig's results in the Marine Corp Marathon the weekend before, that had to move up a little. I decided that since Craig had run a 3:50, I might as well set a PR and break 3:48. So I checked with Paul, who was more than happy to shoot for that, and I grabbed pace bands for 3:45.

Once the race started, we settled in behind a pace group leader for a 1:50 half marathon. Strangely, that felt a little bit slow, so we passed her up and pushed on slightly faster. We ran quite evenly, give or take a bit for hills, and by the halfway point, we'd built up about a 6 minute buffer on our 3:45 goal.

By about 24 K, Paul was starting to feel the impact of the faster pace. His goal was sub 4:00 so I pushed on ahead.

At about 30 K I realized that I had 1 hour and 5 minutes to do 12k if I was going to hit my goal of 3:45. That was not a happy hour to look forward to at that point, so I focused on doing the next kilometer in under 5 minutes, and the next, and so on. I saw Paul again about a minute behind me from the out-and-back turnaround point, so that was good!

With about 3K to go I got the idea that I could break 3:40 if I just held it together for a couple more Ks. I choked down half a cup of water at the last stop and finished with the fastest 3Ks I've done in any marathon finish! It even ended up with a bit of a sprint at the end as I saw that my gun time would be just under 3:40 as well!

I didn't see Paul at the finish line, but I heard the next day at work that he'd come in at 3:58! Kel ran the quarter marathon (10K + change) in 1:15 (a PR for her as well), so a great day all around.



Km Elapsed Split Notes
1 ??? (5:21)
2 10:43 (5:21) 10:43
3 15:26 4:43
4 20:55 5:28 w
5 25:32 4:37
6 30:23 4:50
7 35:10 4:46
8 40:10 5:00 w
9 ??? (5:17) -
10 50:46 (5:17) 10:35
11 55:43 4:56
12 1:01:14 5:31
13 ??? (5:15)
14 ??? (5:15)
15 ??? (5:15)
16 1:22:15 (5:15) w21:01
17 1:27:33 5:17
18 1:33:42 6:09 Long?
19 1:37:40 3:58 Short?
20 1:43:05 5:24 -10k 52:29
21 1:48:24 5:19
22 1:54:32 6:07 w-
23 1:59:49 5:17
24 2:05:03 5:13
25 2:10:02 4:58 left Paul. (avg 5:12 -> 5:09)
26 2:14:57 4:55 w
27 2:20:06 5:09
28 2:25:02 4;56
29 ??? (5:07) w
30 2:35:17 (5:07) 10:15 -10k 52:12
31 ??? (5:12)
32 2:45:43 (5:12) w10:25
33 2:50:55 5:12
34 2:55:44 4:48
35 3:01:00 5:16 w
36 3:05:56 4:55
37 3:11:22 5:25
38 3:16:40 5:18
39 3:22:18 5:37 w
40 3:27:30 5:11 -10k 52:13
41 ??? (5:10)
42 ??? (5:10)
42.2 3:38:53 (1:02) 11:23

8:20 miles
5:11 ks