Gavin Draper's Blog

Father, Developer, Tech Geek, Extreme Sports Fanatic

@gavdraper | +gavdraper | github | StackOverflow Careers
 

Using TDD To Create A Working Application In C# : Part 1

In this series of blog posts I am going to go through step by step how to create a working application in C# by using the Test Driven Development process.

The Application

The application that I am going to build is a 1 page site that allows users to enter their favourite artist and track title then it will suggest other music they may like. The reason I have choose this is its relatively simple but at the same time covers a lot of the key TDD areas.

Tools

  • VS2010
  • ASP.Net MVC 3
  • Entity Framework 4
  • NuGet
  • LastFM Application Key for their API.
  • Moq
  • SQL Server 2005+ (Probably will work on 2000)

Features

What we are going to create is a 1 page Asp.Net MVC site with a search form for finding similar tracks, a results area to show the similar tracks and another area to list recent searches. I’ll be using the Last FM REST API to find the similar music (specifically the track.getSimilar call), to make the REST calls we’re going to use RestSharp a .Net library for accessing REST services. I’m going to use the built in Visual Studio unit test framework, if you don't have this in your version you’ll be able to use nUnit or any other unit testing framework with minimal changes.

Configuring The Solution

In Visual Studio take the following steps

  1. File New, Other Project Types, Visual Studio Solutions
  2. Create a blank solution called “TDDMusicMatch”
  3. Add a new ASP.Net MVC 3 Web Application called “TDDMusicMatch.Web” with these options
       newmvcproject
  4. Add a new test project called “TDDMusicMatch.Tests”
  5. Delete UnitTest1.cs from the test project

The solution should then look like this

solutionMusicMatch

In part 2 we will go through creating our first unit tests…


 
comments powered by Disqus