We’re rewarding the question askers & reputations are being recalculated! Read more.
6 deleted 13 characters in body; edited title
source | link

Does this follow proper xSpec style? Unit tests for the SquishIt framework

For a little background, I'm a contributor to SquishIt and decided that I should start cleaning up the mess of unit tests (my updated version of one set of tests vs. original set of tests). After tackling only part of the "rewrite", I figured it would be a good opportunity to learn, try, and understand BDD style testing to hopefully help improve the unit tests being written and ran. I decided to go with NSpec after taking a look at some of the choices out there.

My problem is simply trying to break the tests down into the appropriate "groupings" that logically make sense and "conform" to xSpec. Here is what I've done so far and passes all tests as expected:

EDIT:

using NSpec;
using SquishIt.Framework;
using SquishIt.Framework.JavaScript;

namespace SquishIt.Tests
{
    class describe_JavaScriptBundle : nspec
    {
        public JavaScriptBundle bundle;

        public void AddTest1JS()
        {
            bundle.Add("test.js");
        }
    }

    class when_I_create_a_bundle : describe_JavaScriptBundle
    {
        void before_each()
        {
            if (bundle == null)
            {
                bundle = Bundle.JavaScript();
            }
        }

        void and_add_no_files()
        {
            it["GroupBundles containskey default"] = () => bundle.GroupBundles.ContainsKey("default").is_true();
            it["has no Assets"] = () => bundle.GroupBundles["default"].Assets.Count.Is(0);
        }
    }

    class then_I_add_a_file : when_I_create_a_bundle
    {
        void before_each()
        {
            AddTest1JS();
        }

        void it_should_contain_only_one_file()
        {
            bundle.GroupBundles["default"].Assets.Count.Is(1);
        }
    }

    class then_I_add_the_same_file : then_I_add_a_file
    {
        void it_should_still_contain_only_one_file()
        {
            bundle.GroupBundles["default"].Assets.Count.Is(1);
        }
    }
}

How can I improve this or am I already on the right track?

Does this follow proper xSpec style?

For a little background, I'm a contributor to SquishIt and decided that I should start cleaning up the mess of unit tests (my updated version of one set of tests vs. original set of tests). After tackling only part of the "rewrite", I figured it would be a good opportunity to learn, try, and understand BDD style testing to hopefully help improve the unit tests being written and ran. I decided to go with NSpec after taking a look at some of the choices out there.

My problem is simply trying to break the tests down into the appropriate "groupings" that logically make sense and "conform" to xSpec. Here is what I've done so far and passes all tests as expected:

EDIT:

using NSpec;
using SquishIt.Framework;
using SquishIt.Framework.JavaScript;

namespace SquishIt.Tests
{
    class describe_JavaScriptBundle : nspec
    {
        public JavaScriptBundle bundle;

        public void AddTest1JS()
        {
            bundle.Add("test.js");
        }
    }

    class when_I_create_a_bundle : describe_JavaScriptBundle
    {
        void before_each()
        {
            if (bundle == null)
            {
                bundle = Bundle.JavaScript();
            }
        }

        void and_add_no_files()
        {
            it["GroupBundles containskey default"] = () => bundle.GroupBundles.ContainsKey("default").is_true();
            it["has no Assets"] = () => bundle.GroupBundles["default"].Assets.Count.Is(0);
        }
    }

    class then_I_add_a_file : when_I_create_a_bundle
    {
        void before_each()
        {
            AddTest1JS();
        }

        void it_should_contain_only_one_file()
        {
            bundle.GroupBundles["default"].Assets.Count.Is(1);
        }
    }

    class then_I_add_the_same_file : then_I_add_a_file
    {
        void it_should_still_contain_only_one_file()
        {
            bundle.GroupBundles["default"].Assets.Count.Is(1);
        }
    }
}

How can I improve this or am I already on the right track?

Unit tests for the SquishIt framework

For a little background, I'm a contributor to SquishIt and decided that I should start cleaning up the mess of unit tests (my updated version of one set of tests vs. original set of tests). After tackling only part of the "rewrite", I figured it would be a good opportunity to learn, try, and understand BDD style testing to hopefully help improve the unit tests being written and ran. I decided to go with NSpec after taking a look at some of the choices out there.

My problem is simply trying to break the tests down into the appropriate "groupings" that logically make sense and "conform" to xSpec. Here is what I've done so far and passes all tests as expected:

using NSpec;
using SquishIt.Framework;
using SquishIt.Framework.JavaScript;

namespace SquishIt.Tests
{
    class describe_JavaScriptBundle : nspec
    {
        public JavaScriptBundle bundle;

        public void AddTest1JS()
        {
            bundle.Add("test.js");
        }
    }

    class when_I_create_a_bundle : describe_JavaScriptBundle
    {
        void before_each()
        {
            if (bundle == null)
            {
                bundle = Bundle.JavaScript();
            }
        }

        void and_add_no_files()
        {
            it["GroupBundles containskey default"] = () => bundle.GroupBundles.ContainsKey("default").is_true();
            it["has no Assets"] = () => bundle.GroupBundles["default"].Assets.Count.Is(0);
        }
    }

    class then_I_add_a_file : when_I_create_a_bundle
    {
        void before_each()
        {
            AddTest1JS();
        }

        void it_should_contain_only_one_file()
        {
            bundle.GroupBundles["default"].Assets.Count.Is(1);
        }
    }

    class then_I_add_the_same_file : then_I_add_a_file
    {
        void it_should_still_contain_only_one_file()
        {
            bundle.GroupBundles["default"].Assets.Count.Is(1);
        }
    }
}

How can I improve this or am I already on the right track?

5 Corrected spelling
source | link

For a little background, I'm a contributor to SquishIt and decided that I should start cleaning up the mess of unit tests (my updated version of one set of tests vs. original set of tests). After tackling only part of the "rewrite", I figured it would be a good opportunity to learn, try, and understand BDD style testing to hopefully help improve the unit tests being written and ran. I decided to go with NSpec after taking a look at some of the choices out there.

My problem is simply trying to break the tests down into the appropriate "groupings" that logically make sense and "conform" to xSpec. Here is what I've done so far and passes all tests as expected:

EDIT:

using NSpec;
using SquishIt.Framework;
using SquishIt.Framework.JavaScript;

namespace SquishIt.Tests
{
    class describe_JavaScriptBundle : nspec
    {
        public JavaScriptBundle bundle;

        public void AddTest1JS()
        {
            bundle.Add("test.js");
        }
    }

    class when_I_create_a_bundle : describe_JavaScriptBundle
    {
        void before_each()
        {
            if (bundle == null)
            {
                bundle = Bundle.JavaScript();
            }
        }

        void and_add_no_files()
        {
            it["GroupBundles containskey default"] = () => bundle.GroupBundles.ContainsKey("default").is_true();
            it["has no Assets"] = () => bundle.GroupBundles["default"].Assets.Count.Is(0);
        }
    }

    class then_I_add_a_file : when_I_create_a_bundle
    {
        void before_each()
        {
            AddTest1JS();
        }

        void it_should_contain_only_one_file()
        {
            bundle.GroupBundles["default"].Assets.Count.Is(1);
        }
    }

    class then_I_add_the_same_file : then_I_add_a_file
    {
        void it_should_still_contain_only_one_file()
        {
            bundle.GroupBundles["default"].Assets.Count.Is(1);
        }
    }
}

How can I improve this or am I already on the writeright track?

For a little background, I'm a contributor to SquishIt and decided that I should start cleaning up the mess of unit tests (my updated version of one set of tests vs. original set of tests). After tackling only part of the "rewrite", I figured it would be a good opportunity to learn, try, and understand BDD style testing to hopefully help improve the unit tests being written and ran. I decided to go with NSpec after taking a look at some of the choices out there.

My problem is simply trying to break the tests down into the appropriate "groupings" that logically make sense and "conform" to xSpec. Here is what I've done so far and passes all tests as expected:

EDIT:

using NSpec;
using SquishIt.Framework;
using SquishIt.Framework.JavaScript;

namespace SquishIt.Tests
{
    class describe_JavaScriptBundle : nspec
    {
        public JavaScriptBundle bundle;

        public void AddTest1JS()
        {
            bundle.Add("test.js");
        }
    }

    class when_I_create_a_bundle : describe_JavaScriptBundle
    {
        void before_each()
        {
            if (bundle == null)
            {
                bundle = Bundle.JavaScript();
            }
        }

        void and_add_no_files()
        {
            it["GroupBundles containskey default"] = () => bundle.GroupBundles.ContainsKey("default").is_true();
            it["has no Assets"] = () => bundle.GroupBundles["default"].Assets.Count.Is(0);
        }
    }

    class then_I_add_a_file : when_I_create_a_bundle
    {
        void before_each()
        {
            AddTest1JS();
        }

        void it_should_contain_only_one_file()
        {
            bundle.GroupBundles["default"].Assets.Count.Is(1);
        }
    }

    class then_I_add_the_same_file : then_I_add_a_file
    {
        void it_should_still_contain_only_one_file()
        {
            bundle.GroupBundles["default"].Assets.Count.Is(1);
        }
    }
}

How can I improve this or am I already on the write track?

For a little background, I'm a contributor to SquishIt and decided that I should start cleaning up the mess of unit tests (my updated version of one set of tests vs. original set of tests). After tackling only part of the "rewrite", I figured it would be a good opportunity to learn, try, and understand BDD style testing to hopefully help improve the unit tests being written and ran. I decided to go with NSpec after taking a look at some of the choices out there.

My problem is simply trying to break the tests down into the appropriate "groupings" that logically make sense and "conform" to xSpec. Here is what I've done so far and passes all tests as expected:

EDIT:

using NSpec;
using SquishIt.Framework;
using SquishIt.Framework.JavaScript;

namespace SquishIt.Tests
{
    class describe_JavaScriptBundle : nspec
    {
        public JavaScriptBundle bundle;

        public void AddTest1JS()
        {
            bundle.Add("test.js");
        }
    }

    class when_I_create_a_bundle : describe_JavaScriptBundle
    {
        void before_each()
        {
            if (bundle == null)
            {
                bundle = Bundle.JavaScript();
            }
        }

        void and_add_no_files()
        {
            it["GroupBundles containskey default"] = () => bundle.GroupBundles.ContainsKey("default").is_true();
            it["has no Assets"] = () => bundle.GroupBundles["default"].Assets.Count.Is(0);
        }
    }

    class then_I_add_a_file : when_I_create_a_bundle
    {
        void before_each()
        {
            AddTest1JS();
        }

        void it_should_contain_only_one_file()
        {
            bundle.GroupBundles["default"].Assets.Count.Is(1);
        }
    }

    class then_I_add_the_same_file : then_I_add_a_file
    {
        void it_should_still_contain_only_one_file()
        {
            bundle.GroupBundles["default"].Assets.Count.Is(1);
        }
    }
}

How can I improve this or am I already on the right track?

    Tweeted twitter.com/#!/StackCodeReview/status/102509792400125953
4 deleted 21 characters in body
source | link

EDIT:

using NSpec;
using SquishIt.Framework;
using SquishIt.Framework.JavaScript;

namespace SquishIt.Tests
{
    class describe_JavaScriptBundle : nspec
    {
        public JavaScriptBundle bundle;

        public void AddTest1JS()
        {
            bundle.Add("test.js");
        }
    }

    class when_I_create_a_bundle : describe_JavaScriptBundle
    {
        void before_each()
        {
            if (bundle == null)
            {
                bundle = Bundle.JavaScript();
            }
        }

        void it_GroupBundles_contains_key_defaultand_add_no_files()
        {  
      
       it["GroupBundles containskey default"] = () => bundle.GroupBundles.ContainsKey("default").is_true();
        }

     it["has no Assets"] void= it_aas_no_Assets()
        {
           => bundle.GroupBundles["default"].Assets.Count.Is(0);
        }
    }

    class when_I_add_a_filethen_I_add_a_file : when_I_create_a_bundle
    {
        void before_each()
        {
            AddTest1JS();
        }

        void it_should_contain_only_one_file()
        {
            bundle.GroupBundles["default"].Assets.Count.Is(1);
        }
    }

    class when_I_add_the_same_filethen_I_add_the_same_file : when_I_add_a_filethen_I_add_a_file
    {
        void it_should_still_contain_only_one_file()
        {
            bundle.GroupBundles["default"].Assets.Count.Is(1);
        }
    }
}
using NSpec;
using SquishIt.Framework;
using SquishIt.Framework.JavaScript;

namespace SquishIt.Tests
{
    class describe_JavaScriptBundle : nspec
    {
        public JavaScriptBundle bundle;

        public void AddTest1JS()
        {
            bundle.Add("test.js");
        }
    }

    class when_I_create_a_bundle : describe_JavaScriptBundle
    {
        void before_each()
        {
            if (bundle == null)
            {
                bundle = Bundle.JavaScript();
            }
        }

        void it_GroupBundles_contains_key_default()
        {       
             bundle.GroupBundles.ContainsKey("default").is_true();
        }

        void it_aas_no_Assets()
        {
            bundle.GroupBundles["default"].Assets.Count.Is(0);
        }
    }

    class when_I_add_a_file : when_I_create_a_bundle
    {
        void before_each()
        {
            AddTest1JS();
        }

        void it_should_contain_only_one_file()
        {
            bundle.GroupBundles["default"].Assets.Count.Is(1);
        }
    }

    class when_I_add_the_same_file : when_I_add_a_file
    {
        void it_should_still_contain_only_one_file()
        {
            bundle.GroupBundles["default"].Assets.Count.Is(1);
        }
    }
}

EDIT:

using NSpec;
using SquishIt.Framework;
using SquishIt.Framework.JavaScript;

namespace SquishIt.Tests
{
    class describe_JavaScriptBundle : nspec
    {
        public JavaScriptBundle bundle;

        public void AddTest1JS()
        {
            bundle.Add("test.js");
        }
    }

    class when_I_create_a_bundle : describe_JavaScriptBundle
    {
        void before_each()
        {
            if (bundle == null)
            {
                bundle = Bundle.JavaScript();
            }
        }

        void and_add_no_files()
        { 
            it["GroupBundles containskey default"] = () => bundle.GroupBundles.ContainsKey("default").is_true();
            it["has no Assets"] = () => bundle.GroupBundles["default"].Assets.Count.Is(0);
        }
    }

    class then_I_add_a_file : when_I_create_a_bundle
    {
        void before_each()
        {
            AddTest1JS();
        }

        void it_should_contain_only_one_file()
        {
            bundle.GroupBundles["default"].Assets.Count.Is(1);
        }
    }

    class then_I_add_the_same_file : then_I_add_a_file
    {
        void it_should_still_contain_only_one_file()
        {
            bundle.GroupBundles["default"].Assets.Count.Is(1);
        }
    }
}
3 Fixed another bug
source | link
2 deleted 1 characters in body
source | link
1
source | link