Aubergine (BDD for .net) v0.06 : support for parameter tables in given/when/then

by Tom 12. November 2009 05:30

Ok, we keep on going; now we support parameter tables for given/when/then, which are parsed as array members.

I am now getting very close to full cucumber-like support !!! Oh, I forgot to mention that the "And" keyword is also supported now !!

An example of the new syntax:


Context    Be.Corebvba.Aubergine.Examples.Website.Contexts.BrowserContext
ContextDLL Be.Corebvba.Aubergine.Examples.DLL

Story Make sure my website gets enough visibility
    As a website owner
    I want to make sure that I get enough visibility
    So that I can get enough traffic

    Scenario Search results for 'keywords' on searchengine should contain 'www.corebvba.be'
        Given the current url is 'search url'
        When searching for 'keywords'
        Then the result should contain 'www.corebvba.be'
        Example
        +--------------+--------------------------------+------------------+
        | searchengine | search url                     | keywords         |
        +--------------+--------------------------------+------------------+
        | google       | http://www.google.be/search?q= | BDD .Net         |
        | bing         | http://www.bing.com/search?q=  | core bvba tom    |
        | bing         | http://www.bing.com/search?q=  | Quantum physics  |
        | faulty link  | http://www.googleaaa           | core bvba tom    |
        +--------------+--------------------------------+------------------+


    Scenario Search results on google for keywords should contain 'www.corebvba.be'
        Given the current url is 'http://www.google.be/search?q='
        When searching for the following keywords
            +-----------+
            | keywords  |
            +-----------+
            | Aubergine |
            | BDD       |
            +-----------+
        Then the result should contain 'www.corebvba.be' and the following markup elements
            +------------------+
            | type | inner     |
            +------------------+
            | em   | BDD       |
            | em   | Aubergine |
            +------------------+

And the context :


    public class BrowserContext
    {
        public string Url { get; set; }
        public string Result { get; set; }

        private WebClient wc = new WebClient();
           
        [DSL("the current url is '(?<url>.*)'")]
        void SetUrl(string url)
        {
            Url = url;
        }

        [DSL("searching for '(?<keywords>.*)'")]
        void SearchForKeyWords(string keywords)
        {
            Result = wc.DownloadString(Url + HttpUtility.UrlEncode(keywords));
        }

        [DSL("searching for the following keywords")]
        void SearchForKeyWords(string[] keywords)
        {
            Result = wc.DownloadString(Url + HttpUtility.UrlEncode(string.Join(" ",keywords)));
        }


        [DSL("the result should contain '(?<myurl>.*)'")]
        bool ResultShouldContain(string myurl)
        {
            return (Result??"").Contains(myurl);
        }

        [DSL("the result should contain '(?<avalue>.+)' and the following markup elements")]
        bool ResultShouldContain(string avalue,string[] type,string[]inner)
        {
            if (string.IsNullOrEmpty(Result) ||type.Length==0)
                return false;
            if (!Result.Contains(avalue)) return false;
            for (var i = 0;i < type.Length ; i++)
            {
                var searchstring = string.Format("<{0}>{1}</{0}>", type[i], inner[i]);
                if (!Result.Contains(searchstring))
                    return false;
            }
            return true;
        }
    }

It looks a bit messy, but thats because it is a stupid example. A good example would be loading a repository with some products.

Download it here !!

Auberginev0.06.zip (41,70 kb)

Enjoy !!

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, object-oriented and functional languages.
As he matured in software coding, he started focusing 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...

**** Hire me ! ****

My current project will probably run till the end of August 2013. Feel free to contact me for a project later on.

I can work either in Belgium or via remote access!!!

You can find my resume here: resume.pdf .

Community contributions and publications: here .

Call me directly at +32 478 336 376


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