A colleague of mine recently hit upon an odd issue with the Sitecore integration for the 51Degrees browser detection service. It worked fine for most of his testing, but raised an exception in some circumstances. Trying to dig into this and create a test to demonstrate the bug kept us amused for a few hours – maybe it will help you to? Continue reading
Have you ever needed to write code that detects if the current computer has an internet connection or not? Having recently tried this, it turns out it’s not quite as easy as I expected it would be. So since I’ve banged my head against the challenge, here’s one approach to solving the problem that you might find useful: Continue reading
One of the things that the masters of Unit Testing say is that tests should always be repeatable and deterministic. No matter when, or how many times you run a test, if the System Under Test stays the same, the results of the test should stay the same. So I found myself a bit confused recently when some tests went from reliable to unreliable results. Turns out the tests were right, and they were pointing out a silly bug I’d introduced by accident… Continue reading
Every so often, every developer finds themselves having to parse data out of text. There are loads of ways of approaching this task, but a lot of pretty unsatisfactory solutions start from “I’ll just split up the text by whitespace” or “Hey, let’s use regular expressions!”. You all remember what regular expressions lead to, right?
As someone who’s always on the lookout for something interesting and new to experiment with, I came across an alternative approach to parsing text recently. A blog post I read (I forget what it was, or I’d give credit) linked to the Sprache project on GitHub. This is a text parsing library which lets you construct the descriptions of the text to parse using Linq-style expressions.
So I thought I’d invent an idea for an experimental project to test this out… Continue reading