Monthly Archives: March 2014

My new (as good as) Burley D’lite #cycling

An as good as new Burley D’lite came up on eBay (used once), this thing is in mint condition, so I paid the buy it now price and got family to collect it and deliver it to me.
“But you already have a Burley?”
Yes, a Solo, but now I have two kids (note to self, can’t have any more because they don’t make a triple seater).
My family didn’t understand why I paid so much and didn’t bid, I overpaid, until they saw one go for more money a week later.
Plus I like the blue an yellow, Halfords only have an orange ugly version and £235 more than I paid.

It’s got big 20″ wheels:
20140315-211905.jpg

A big boot:
20140315-212435.jpg

20140315-211932.jpg

My favourite improvement over the old Solo is the clip buckle rather than poppers for accessing the boot
20140315-212410.jpg

The Thorn Raven Sport Tour / Rohloff friendly (standard forged) mount
20140315-211948.jpg

The tissue paper still in the rain cover, I told you it was as new
20140315-212006.jpg

Until I took it out…
20140315-212302.jpg

Most importantly it has two seats, though moving the straps and position it can sit a single child
20140315-212347.jpg

Half a day of clearing out the shed and…. Ta da! (The two flags are just out of shot.)
20140315-212530.jpg

In more or less perfect alignment for hitching up to Bluebell when I need it
20140315-212546.jpg

Have I used it yet? No, I’ve had a bad cold and have barely managed any miles since I got it 😦

Advertisements

Detouring a constructor with Microsoft Fakes #dev #coding #tdd

I wanted to ensure every SmtpClient instance that was created by a library was also disposed of, to do this I first needed to Shim SmtpClient using Microsoft Fakes:

  1. Add Fakes Assembly for System.
  2. Edit Fakes/System.fakes
    Add

    <ShimGeneration>
      <Add TypeName="SmtpClient"/>
    </ShimGeneration>
  3. Save the file and close
  4. Rebuild, open the System.4.0.0.0.Fakes reference and under System.Net.Mail.Fakes you should see ShimSmtpClient.

My idea was to count up every time the constructor was called and to count down every time one was disposed, to do this I created a counter:

int instancesNotDispose = 0;

Incremented it in the Constructor Shim, that is wrap the constructor and do some more things rather than completely detouring the constructor:

ShimSmtpClient.Constructor =
    x =>
    {
        // Execute outside of Shims otherwise you'll be in StackOverflowException territory
        ShimsContext.ExecuteWithoutShims(
        () =>
        {
            // Use reflection to get the default constructor and invoke it, the magic here is the instance is stashed into x!
            var constructor = typeof(SmtpClient).GetConstructor(new Type[0]);
            constructor.Invoke(x, new Object[0]);
        });

        instancesNotDispose++;
    };

Then decremented it in the Dispose Shim:

ShimSmtpClient.AllInstances.Dispose =
    x =>
    {
        // Execute outside of Shims otherwise you'll be in StackOverflowException territory
        ShimsContext.ExecuteWithoutShims(x.Dispose);

        instancesNotDispose--;
    };

Then I can call my library a bunch of times to do whatever it does and sends some e-mails, then I can assert they have all be disposed:

Assert.AreEqual<int>(0, instancesNotDispose, String.Format("Doh! {0} were not disposed", instancesNotDispose));

Assuming there aren’t other SmtpClient constructors that do not call the default constructor then this code should work fine, if there are other constructors called that do not call the default constructor then this Assert will also help find those. There are other ways, for example, stashing each instance in a List and ensuring each is in both the Constructor List and the Dispose List, but this counting approach was enough for my needs for now.

A new chainring and pedal reflectors, yes, you heard me. #cycling

Lastly, firstly, pedal reflectors are a legal requirement in the UK, other than that, I think they are worthwhile, they can’t do any harm. Don’t be fooled though, reflectors give people false hope, get decent lights, spend a lot of money on them and be safe. Pedal reflectors won’t help when the vehicle’s windows are misted up or it’s a rainy day. Only bright lights will penetrate that.

But anyway… I was down to my last one, they keep breaking, falling off etc. So I bought some new bolt on ones, let’s see how long they last.

Now, the highlight, a brand spanking new Thorn chainring, 48T and reversible (eat that derailleur lovers):

20140305-151500.jpg

Notice how clean Bluebell is compared with normal? I treated her to a clean not so long ago 🙂

Also, note the black oil marks are on alternate teeth, bonus points if you can guess why this is? Wow, cycling trivia, almost.

And for comparison old against new:

20140305-151937.jpg

Extra trivia, is the original (on top) a reversible chainring and explain why 🙂