Click here to Skip to main content
Click here to Skip to main content

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"
"$(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 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 = 
		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 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 !!

License

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 Core bvba
Belgium Belgium
Tom Janssens, owner of Core, a software and consultancy company.
Father of two sons named Quinten & Matisse, and married to a beautiful woman named Liesbeth.
 
Blog: http://tojans.me
Github: http://github.com/ToJans
Twitter: http://twitter.com/ToJans
LinkedIn: http://www.linkedin.com/in/tomjanssens

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web04 | 2.8.140709.1 | Last Updated 21 Oct 2009
Article Copyright 2009 by Tom Janssens
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid