w00t : Building a new app from the ground up : First specs and getting started

by Tom 19. October 2009 09:21
This is one of the articles in our series; the parts are:
  1. Methodology, technology & tools used
  2. Setting up the environment
  3. First specs and getting started
  4. IOC, database and other stuff; a real framework 

 Happy reading !

Automating specs 

Ok, this step took quite some time to figure out, but once you know how to do this this should be really simple.

1. Open the solution and go to the properties of the Specs project
2. Go to the build events, and put the following text in the post-build event command line :

del "$(TargetDir)*.html"
"$(ProjectDir)..\..\tools\Machine.Specifications.ConsoleRunner.exe" "$(TargetPath)" --html $(TargetDir) 
ren "$(TargetDir)$(TargetName)*.html" output.html
"$(TargetDir)output.html"
exit 0 

This will make sure that everytime you do a build, the old Mspec html file  gets deleted, mspec is ran, and the html is renamed to output.html and shown in your default browser.

Please do note that as long as you have the browser open, you build will not be considered finished, so you should close this window in order to continue developing.
Another possibility would be to build the html file somewhere in your project path, and add it to the project, so you can load it in your project each time, and get a message if it has changed.

3. Add a reference to ..\lib\Machine.specifications.dll
4. Remove the bogus class and start writing your specs.

Regarding this part there might be some discussions. I created a file called ProductSpecs.cs, which has the following content :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Machine.Specifications;
namespace Specs
{
    public class Product { };
    public interface IRepository<T>
    {
        IQueryable<T> Find {get;}
        bool Add(T instance);
        bool Delete(T instance);
        bool Update(T instance);
    }
    public interface IUnitOfWork : IDisposable 
    {
        void Commit();
    }
    public interface IProductRepository : IRepository<Product>
    {
         ICollection<Product> GetFromXml(string xml);
    };
    public abstract class with_empty_productlist
    {
        protected static IProductRepository productrepo;
        protected static ICollection<Product> products;
        Establish context = () => 
            {
                products = new List<Product>();
            };
    }
    public abstract class with_productlist : with_empty_productlist
    {
        Establish context = () =>
        {
            products = new List<Product>();
            products.Add(new Product());
            products.Add(new Product());
            products.Add(new Product());
        };
    }
    public class when_products_are_imported_from_external_xmlfile : with_productlist
    {
        Because of = () => products = productrepo.GetFromXml(Properties.Resources.ExternalProductsXml);
        It should_contain_xx_products;
        It should_have_an_article_matching_xx;
    }
}

So as you might see I added some of my code to be in order to be able to start writing some code in my specs; the next thing I am going to do is write code to match these simple specs, and move the respective app code in a proper project of it's own.

Once this is finished, I am going to extend my specs to match a bigger part of the scope...

I'll keep you all posted !!

Bookmark and Share

About Tom

Tom Janssens op LinkedIn

Tom Janssens op twitter

Core bvba RSS

 

Tom Janssens is an independent freelance ICT consultant that has been "into computers" ever since the age of 7.

Typing source code from a book evolved into exploring the limits of coding in procedural, assembly and object-oriented languages.
As he matured in software coding, he started focussing on the problems surrounding software development, and learned that software development is usually about people and interactions first, and about technology second.

Due to his diverse track record he gained insights in a lot of aspects of the software development process. Currently his main focus is on strategic ICT advice, lean product/project development and improving the software development process and architecture.

He avoids ivory-tower-approaches by applying and verifying the applicability of the latest tech buzz in software experiments.

He is also the founder of the following LinkedIn groups:

CQRS Professional
BDD Professional
Asp.Net MVC professional

More info about Tom and his company...


Advertisement

Forget all your SCRUM -, Kanban - and other Agile and Lean certificates

Here is the only true AGILE and LEAN certificate you will ever need:

The Creative Recursive Analysis Process Certificate
(CRAP Certificate for short)

More info can be found at the official CRAP certificate website:
http://bit.ly/CRAPCertificate