Building a service driven mobile app (Part 2)

## Part 2: Configuring the Tools

5. ### Visual Studio Express configuration

My development skills are the strongest within the Microsoft stall, so I’ll be using [Visual Studio 2010 Express edition][1] with [SQL Express R2][2] and [Windows Azure Tools for Microsoft Visual Studio 1.3][3].

[1]:http://www.microsoft.com/express/Web
[2]:http://www.microsoft.com/express/Database
[3]:http://www.microsoft.com/downloads/en/details.aspx?FamilyID=7a1089b6-4050-4307-86c4-9dadaa5ed018&displaylang=en “”


*Hint: SQL Express R2 adds the ability to use SQL Server Management Studio to connect to Azure SQL tables and at least view data and run scripts against it, which helps a lot.*

6. ### Springloops

[Springloops.com v2][4] now allows one to source control your code and has a nice ticketing tool as well, for free (at least for the moment). So I created an account and project for my source code. You’ll need a subversion client and I chose [Tortoise SVN][5] for Windows to check code in and out.
[4]:http://www.springloops.com/v2/
[5]:http://tortoisesvn.tigris.org/


7. ### SpecFlow and NUnit

See [specflow.org][6] for more info, but essentially this little tool allows one to automatically create a set of unit test classes from .feature files. These .feature files each contain a feature definition and a collection of scenario definitions, all in the easy-to-read Gherkin syntax. The generated tests can be executed with either Microsoft’s Visual Studio Test Tools or with [NUnit][7]. SpecFlow easily integrates with the IDE when you have Visual Studio Standard and above, but for the Express edition only NUnit is supported and you’ll need to configure SpecFlow by hand, the post [C# ATDD on a shoestring][8] got me started and below is a summary (with my own alterations) of what needs to be done:
> – Download and install [SpecFlow][9]
> – Download and install [NUnit][10]
> – Add the Specflow directory (C:Program FilesTechTalkSpecFlow or similar) and the NUnit directory (C:Program FilesNUnit 2.5.9binnet-2.0 or similar) to your [Windows Path][11]
> – Download and unzip the [SpecFlow templates][12] and place the .zip files (SpecFlowFeature.zip, SpecFlowStepDefinition.zip etc.) into your Visual Studio 2010 Express C# templates directory (usually: C:UsersusernameDocumentsVisual Studio 2010TemplatesItemTemplatesVisual C# or similar).
> – Enable Expert Settings in Visual Studio found here: Tools->Settings->Expert Settings
> – Create a batch file called [download id=”4″] and place it in the installed SpecFlow folder, usually C:Program FilesTechTalkSpecFlow with the following commands

[text]
@echo off
echo Starting to generate SpecFlow unit tests
SpecFlow generateAll %1 /force /verbose
echo Finished generating SpecFlow unit tests
[/text]

> – Add an external tool to Visual Studio from Tools->External Tools->Add with Title: **Generate SpecFlow Tests**, Command: **generatespecflowtests.bat**, Arguments: **$(ProjectDir)$(ProjectFileName)** and Initial Directory: **$(ProjectDir)**
> – Add another external tool with Title: **Run SpecFlow Tests (Debug)**, Command: **nunit.exe**, Arguments: **$(ProjectDir)$(ProjectFileName)** and Initial Directory: $(ProjectDir)binDebug

####Enable Debugging of tests

Just a note that it is possible to debug your tests with NUnit and Visual Studio Express. Assuming you have already setup a specs class library project housing your .feature files and you’ve added references to TechTalk.SpecFlow (from the installed folder) and nunit.framework (from the GAC), if you would like to run the tests in debug mode with Visual Studio attached, you can do the following:
> – Add an additional reference to nunit-console-runner (from the installed folder – in my case C:Program Files (x86)NUnit 2.5.9binnet-2.0lib)
> – Add a class to your project with the following:

> – Change your project’s Output Type to **Console Application** on the Project Properties Dialog -> Application tab and select the class you created in the previous step for Startup Object.
> – Configure Startup Options on the Project Properties Dialog -> Debug tab by setting Command Line Arguments: to **your project file** name e.g. specs.csproj and browse to the **project’s root** for Working Directory:
[6]: http://www.specflow.org
[7]: http://www.nunit.org/
[8]: http://watirmelon.com/2011/02/18/c-sharp-atdd-on-a-shoestring/
[9]: https://github.com/techtalk/SpecFlow/downloads
[10]: http://www.nunit.org/?p=download
[11]: http://geekswithblogs.net/renso/archive/2009/10/21/how-to-set-the-windows-path-in-windows-7.aspx
[12]: https://docs.google.com/leaf?id=0B9L3mPY2rEqmMjM3NDhkYTctM2NjZC00ZWNiLThkZTEtOWI3ODQ5MjljY2Rj&hl=en&authkey=CNf3lLoH

9. ### Subsonic

I’ve decided to focus as much of my development effort as possible on the app’s *behaviour* (which is why I’m following a Behavior Driven Development or BDD methodology) and wanted to guide my development process with a code first pattern. [Subsonic][13]’s SimpleRepository allows just that for my new application.

The following excerpt from [Subsonic][13] sums it up nicely:
> Many people like to work with classes and don’t want to worry about the database implementation – freeing them to work as they want to work without opening up a database designer in order to model their classes. The objects they create a free of base classes and exist on their own, as plain-old CLR objects (also known as POCOs).
>
> If you’re one of these people and you don’t particularly care about the database structure – the SimpleRepository is for you.

To configure Subsonic:
> – Download and install [subsonic][14]
> – Add a reference to SubSonic.Core (found in SubSonic’s installation folder) to your specs project and your class library
> – Create an empty .mdf database in your specs project
> – Create a .config file with the same name as your specs project’s assembly (because of the way our external tool runs the NUnit tests)
> – Add a connectionstring to your empty database in your .config file as follows

> – Click here if you need a [quick demo on how to use SimpleRepository from Subsonic ][14]
[13]:http://www.subsonicproject.com/
[14]:http://subsonicproject.com/docs/Simple_Repo_5_Minute_Demo

Posted in Blog, Develop
Tweets