Click here to Skip to main content
13,004,203 members (79,481 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


1 bookmarked
Posted 19 Oct 2009

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

, 20 Oct 2009
Rate this:
Please Sign up or sign in to vote.
Ok, this step took quite some time to figure out, but once you know how to do this, it is should be really simple...

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 !  

Ok, this step took quite some time to figure out, but once you know how to do this, it 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"
			"$(TargetPath)" --html $(TargetDir) 
ren "$(TargetDir)$(TargetName)*.html" output.html
exit 0 

This will make sure that everytime you do a build, the old Mspec HTML file  gets deleted, mspec is run, 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, your 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.

  1. Add a reference to ..\lib\Machine.specifications.dll
  2. 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 = 
        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 its 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 !!


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Tom Janssens
Founder Virtual Sales Lab
Belgium Belgium

You may also be interested in...

Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170627.1 | Last Updated 21 Oct 2009
Article Copyright 2009 by Tom Janssens
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid