• Taking it Too Far? Unit Testing Your Data Access Code

    05 Mar 2014

    Typically, unit testing your data-access class follows a pretty vanilla pattern. If you're using the repository pattern, for example, it's going to look something like:

    public interface ICustomerRepository {
        Customer Get(int id);
    public class CustomerRepository: ICustomerRepository {
        public Customer Get(int id) {}
    public void Test_Customer_Repository_Returns_Customer_When_Passed_Valid_Id()
        var mockICustomerRepo = new Mock<ICustomerRepository>();
        var customerRepo = new CustomerRepository(mockICustomerRepo.Object);
        mockICustomerRepo.Setup(c => c.Get(1))
            .Returns(new Customer{ Id = 1, FirstName = "Sanjay", LastName = "Uttam"}.Verifiable();
        var result = customerRepo.Get(1);
        //assert some stuff

    That's all fine and well, and it may sufficient in certain applications. But what happens when you want to test whether your repository methods populate objects correctly? Perhaps you've got one or two queries that are still using stored-procedures for performance or legacy reasons. In that case, the above test is really evaluating the correctness of your Get method in the Customer class on the assumption that at run-time, the stored-procedure or query returns the correct data.


  • The Hackers Guide to LinkedIn

    22 Jan 2014

    Most of the time when I'm talking to other technology professionals about LinkedIn, they get pissed off and go into some rant related to LinkedIn being primarily a communication channel for receiving recruiter spam so let's get this out of the way first. You're going to get spammed at least a little. But...


  • Everything That is Wrong With On-Demand Loading

    16 Dec 2013


    I think at some point before AJAX was the norm for consumer-facing web-apps, I probably thought on-demand loading was cool, too. Now, it's usually a usability nightmare. It's even worse if we're talking about responsive sites on mobile devices because they've got to serve a variety of clients on a variety of connection speeds. Last night, while drinking a glass of wine and trying to do some on-line shopping on my phone, I ended up at multiple e-commerce websites that had implemented on-demand loading. None of them nailed it. Some were better than others. The exact use case on all the sites was this:

    1. User selects some category ("Men's Shirts" or "sale")
    2. A list of the first N results is loaded, the user can scrolls vertically (e.g., 1 column, N rows)
    3. When the user gets to the bottom of the results, either the page ajax-loads the next N number, or the user can click to initiate the loading of the next N results.


  • Checking if You're Being Blocked on Outbound Ports

    13 Dec 2013

    Earlier this week I spent some time playing with Redis on my local dev box. Set-up was smooth sailing; install virtual box w/Ubuntu, Redis, set up port forwarding from a host port to a guest port, grab ServiceStack.Redis...I was on my way. Things got a bit more interesting after I deployed Redis to Azure. I changed the configuration in my little console test application to point to the Azure instance. It was running on the default Redis port, 6379. Fired up the console application...tried a SET. Timed out. Tried it again - same result.


  • Executor Process Exited or Exception has Been Thrown by the Target of an Invocation When Attempting to Run Unit Tests

    I came across this error today while moving some source around TFS. I had moved a project from from TFS Project Collection to another, done a get latest and everything built just fine. However, when trying to run unit tests after all the tests were discovered, I saw the "Exception has Been Thrown by the Target of an Invocation When Attempting to Run Unit Tests" error message in the Output window. I figured I'd try doing a get latest and running the tests on my other machine. That worked without issue. That was the first big clue; this had to do with my VS, not the source that was checked in. After trying pretty much everything in this blog post, I did a quick compare on VS versions; noticed the machine where everything was working had Visual Studio Update 3, the machine that was throwing this error did not. I went ahead and installed that. Great, that had to be it right? WRONG. That just caused me to get a different error, even more nebulous error; "Executor Process Exited". Clearly this was still environmental. Turns out the answer was going into Test Settings and changing the default processor architecture to x64. That is, Test > Test Settings > Default Processor Architecture > x64. Cue unicorns and rainbows.


  • #GraphConnect NYC Coverage

    15 Nov 2013

    Last week I attended the NYC Neo4j Meetup on Data Modeling & Natural Language Search, even better, I happened to win tickets to GraphConnect NYC which was just a few days later. I decided to compile some notes from the event, but rather than just bullet-pointing out the content, I decided to compile a brief synopsis of each of the forums I attended so you know which slides to review or video to check out first. This should be a pretty decent place to start if you're just looking to get your bearings when it comes to Graph DBs and Neo4j. There are also a bunch of videos available at http://watch.neo4j.org/.


  • New Everything

    15 Nov 2013

    Well...I finally got around to tweaking my blog, and in theory that will mean I actually get to writing a bit more. This instance of my blog is running on Sandra Snow. It's basically a port of Jekyll with some additional features, and of course running on .NET (NancyFx) rather than Ruby. The way both of these work is pretty much the same..