Introducing Blink: An Entity Framework Database-reset tool for TDD.

I’ve just started a new open source project you might be interested in if you use both TDD and Entity Framework 6.1.0.

It’s called Blink, and you can get hold of the pre-release binaries on NuGet and the source on GitHub.

Here’s the problem it tries to solve. (If you have this problem, let me know!)

When performing automated testing, it can be very expensive to initialize a fresh, real database. So expensive that you avoid testing against the real database at all costs. For example, the project that inspired me to start this library takes about a minute to build its database; that’s fine in a deployment scenario, but intolerable if you want to write tens or hundreds of integration tests. Blink re-initialises the DB in ~3s. That’s fast enough for TDD, if you’re careful about which tests you run.

It’s a very young project, currently so young it’s not really designed to be used on other people’s machine’s quite yet — there are some hard-coded strings that need replacing before it’ll work on anything other than a default instance of SQL Server 2012 x64, for instance. That’ll come soon, though.

This blog post is more of an announcement, though. If you’re interested, get in touch via the comments. Let me know if the project looks useful to you. We’ll see if we can’t make something good.

Here’s roughly what the code looks like;

// Create a new BlinkDBFactory, maybe inside [TestInitialize] or [SetUp]
var factory = Blink.BlinkDB.CreateDbFactory<TestDbContext, TestDbConfiguration>(
    BlinkDBCreationMode.UseDBIfItAlreadyExists,
     () => new TestDbContext());

// Execute code, inside a transaction;
factory.ExecuteDbCode(context =>
{
    // use the context here;

});

// db edits are rolled back automatically
Advertisements

Dropbox hack; linking dropbox folders elsewhere on a disk

Dropbox is just about the best way to share files. I’ve tried things like source control, but to be honest, Dropbox just keeps things simple.

However, sometimes you need things like configuration files or data files to live in a particular space on disk, and Dropbox just doesn’t let you sync files in multiple places. Here’s how you can use symbolic links in windows to counterbalance that.

Here’s the example. I use some PowerShell scripts for building software. PowerShell scripts needs to live in

    <my documents>\WindowsPowerShell

So, I store them in

    <dropbox>\Apps\WindowsPowerShell

And then create a symbolic link using the mklink command, like this;

    > mklink /j <my documents>\WindowsPowerShell <dropbox?\Apps\WindowsPowerShell

That is, you specify the new directory first, and the existing directory second. And that’ll give you a folder that appears to be outside dropbox, but which syncs using dropbox.

Now you can do that on multiple PCs and share any number of folders between any number of machines