Skip to main content
added 1 character in body
Source Link
Amir
  • 156
  • 3

Here is how I've written most of my NSpec tests, I usually start a context out with an act. This dry's up the specification. If I find myself doing totoo many "acts", I end up breaking it up into separate specifications.

class describe_JavaScriptBundle : nspec
{
    JavaScriptBundle bundle;

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

    void before_each()
    {
        bundle = Bundle.JavaScript();
    }
    
    void adding_a_bundle()
    {
        context["no files added"] = () =>
        {
            it["GroupBundle contains default key"] = () =>
                bundle.GroupBundles.ContainsKey("default").is_true();

            it["has no Assets"] () => 
                bundle.GroupBundles["default"].Assets.Count.Is(0);
        };
        
        context["adding one file"] = () =>
        {
            act = () => AddTest1JS();
            
            it["contains the file"] = () => 
                bundle.GroupBundles["default"].Assets.Count.Is(1);
            
            context["adding the same file again"] = () =>
            {
                act = () => AddTest1JS();
                
                it["should still only contain one file"] = () => 
                    bundle.GroupBundles["default"].Assets.Count.Is(1);
            };
        };
    }
}

Here is how I've written most of my NSpec tests, I usually start a context out with an act. This dry's up the specification. If I find myself doing to many "acts", I end up breaking it up into separate specifications.

class describe_JavaScriptBundle : nspec
{
    JavaScriptBundle bundle;

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

    void before_each()
    {
        bundle = Bundle.JavaScript();
    }
    
    void adding_a_bundle()
    {
        context["no files added"] = () =>
        {
            it["GroupBundle contains default key"] = () =>
                bundle.GroupBundles.ContainsKey("default").is_true();

            it["has no Assets"] () => 
                bundle.GroupBundles["default"].Assets.Count.Is(0);
        };
        
        context["adding one file"] = () =>
        {
            act = () => AddTest1JS();
            
            it["contains the file"] = () => 
                bundle.GroupBundles["default"].Assets.Count.Is(1);
            
            context["adding the same file again"] = () =>
            {
                act = () => AddTest1JS();
                
                it["should still only contain one file"] = () => 
                    bundle.GroupBundles["default"].Assets.Count.Is(1);
            };
        };
    }
}

Here is how I've written most of my NSpec tests, I usually start a context out with an act. This dry's up the specification. If I find myself doing too many "acts", I end up breaking it up into separate specifications.

class describe_JavaScriptBundle : nspec
{
    JavaScriptBundle bundle;

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

    void before_each()
    {
        bundle = Bundle.JavaScript();
    }
    
    void adding_a_bundle()
    {
        context["no files added"] = () =>
        {
            it["GroupBundle contains default key"] = () =>
                bundle.GroupBundles.ContainsKey("default").is_true();

            it["has no Assets"] () => 
                bundle.GroupBundles["default"].Assets.Count.Is(0);
        };
        
        context["adding one file"] = () =>
        {
            act = () => AddTest1JS();
            
            it["contains the file"] = () => 
                bundle.GroupBundles["default"].Assets.Count.Is(1);
            
            context["adding the same file again"] = () =>
            {
                act = () => AddTest1JS();
                
                it["should still only contain one file"] = () => 
                    bundle.GroupBundles["default"].Assets.Count.Is(1);
            };
        };
    }
}
deleted 1 characters in body
Source Link
Amir
  • 156
  • 3

oHereHere is how I've written most of my NSpec tests, I usually start a context out with an act. This dry's up the specification. If I find myself doing to many "acts", I end up breaking it up into separate specifications.

class describe_JavaScriptBundle : nspec
{
    JavaScriptBundle bundle;

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

    void before_each()
    {
        bundle = Bundle.JavaScript();
    }
    
    void adding_a_bundle()
    {
        context["no files added"] = () =>
        {
            it["GroupBundle contains default key"] = () =>
                bundle.GroupBundles.ContainsKey("default").is_true();

            it["has no Assets"] () => 
                bundle.GroupBundles["default"].Assets.Count.Is(0);
        };
        
        context["adding one file"] = () =>
        {
            act = () => AddTest1JS();
            
            it["contains the file"] = () => 
                bundle.GroupBundles["default"].Assets.Count.Is(1);
            
            context["adding the same file again"] = () =>
            {
                act = () => AddTest1JS();
                
                it["should still only contain one file"] = () => 
                    bundle.GroupBundles["default"].Assets.Count.Is(1);
            };
        };
    }
}

oHere is how I've written most of my NSpec tests, I usually start a context out with an act. This dry's up the specification. If I find myself doing to many "acts", I end up breaking it up into separate specifications.

class describe_JavaScriptBundle : nspec
{
    JavaScriptBundle bundle;

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

    void before_each()
    {
        bundle = Bundle.JavaScript();
    }
    
    void adding_a_bundle()
    {
        context["no files added"] = () =>
        {
            it["GroupBundle contains default key"] = () =>
                bundle.GroupBundles.ContainsKey("default").is_true();

            it["has no Assets"] () => 
                bundle.GroupBundles["default"].Assets.Count.Is(0);
        };
        
        context["adding one file"] = () =>
        {
            act = () => AddTest1JS();
            
            it["contains the file"] = () => 
                bundle.GroupBundles["default"].Assets.Count.Is(1);
            
            context["adding the same file again"] = () =>
            {
                act = () => AddTest1JS();
                
                it["should still only contain one file"] = () => 
                    bundle.GroupBundles["default"].Assets.Count.Is(1);
            };
        };
    }
}

Here is how I've written most of my NSpec tests, I usually start a context out with an act. This dry's up the specification. If I find myself doing to many "acts", I end up breaking it up into separate specifications.

class describe_JavaScriptBundle : nspec
{
    JavaScriptBundle bundle;

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

    void before_each()
    {
        bundle = Bundle.JavaScript();
    }
    
    void adding_a_bundle()
    {
        context["no files added"] = () =>
        {
            it["GroupBundle contains default key"] = () =>
                bundle.GroupBundles.ContainsKey("default").is_true();

            it["has no Assets"] () => 
                bundle.GroupBundles["default"].Assets.Count.Is(0);
        };
        
        context["adding one file"] = () =>
        {
            act = () => AddTest1JS();
            
            it["contains the file"] = () => 
                bundle.GroupBundles["default"].Assets.Count.Is(1);
            
            context["adding the same file again"] = () =>
            {
                act = () => AddTest1JS();
                
                it["should still only contain one file"] = () => 
                    bundle.GroupBundles["default"].Assets.Count.Is(1);
            };
        };
    }
}
added 23 characters in body
Source Link
Amir
  • 156
  • 3

HereoHere is how I've written most of my NSpec tests, I usually start a context out with an act. This dry's up the specification. If I find myself doing to many "acts", I end up breaking it up into separate specifications.

class describe_JavaScriptBundle : nspec
{
    JavaScriptBundle bundle;

    void AddTest1JS()
    {
        bundle.Add("test.js");
    }
    
    void adding_a_bundlebefore_each()
    {
        before = () => bundle = Bundle.JavaScript();
    }
    
    void adding_a_bundle()
    {
        context["no files added"] = () =>
        {
            it["GroupBundle contains default key"] = () =>
                bundle.GroupBundles.ContainsKey("default").is_true();

            it["has no Assets"] () => 
                bundle.GroupBundles["default"].Assets.Count.Is(0);
        };
        
        context["adding one file"] = () =>
        {
            act = () => AddTest1JS();
            
            it["contains the file"] = () => 
                bundle.GroupBundles["default"].Assets.Count.Is(1);
            
            context["adding the same file again"] = () =>
            {
                act = () => AddTest1JS();
                
                it["should still only contain one file"] = () => 
                    bundle.GroupBundles["default"].Assets.Count.Is(1);
            };
        };
    }
}

Here is how I've written most of my NSpec tests, I usually start a context out with an act. This dry's up the specification. If I find myself doing to many "acts", I end up breaking it up into separate specifications.

class describe_JavaScriptBundle : nspec
{
    JavaScriptBundle bundle;

    void AddTest1JS()
    {
        bundle.Add("test.js");
    }
    
    void adding_a_bundle()
    {
        before = () => bundle = Bundle.JavaScript();
        
        context["no files added"] = () =>
        {
            it["GroupBundle contains default key"] = () =>
                bundle.GroupBundles.ContainsKey("default").is_true();

            it["has no Assets"] () => 
                bundle.GroupBundles["default"].Assets.Count.Is(0);
        };
        
        context["adding one file"] = () =>
        {
            act = () => AddTest1JS();
            
            it["contains the file"] = () => 
                bundle.GroupBundles["default"].Assets.Count.Is(1);
            
            context["adding the same file again"] = () =>
            {
                act = () => AddTest1JS();
                
                it["should still only contain one file"] = () => 
                    bundle.GroupBundles["default"].Assets.Count.Is(1);
            };
        };
    }
}

oHere is how I've written most of my NSpec tests, I usually start a context out with an act. This dry's up the specification. If I find myself doing to many "acts", I end up breaking it up into separate specifications.

class describe_JavaScriptBundle : nspec
{
    JavaScriptBundle bundle;

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

    void before_each()
    {
        bundle = Bundle.JavaScript();
    }
    
    void adding_a_bundle()
    {
        context["no files added"] = () =>
        {
            it["GroupBundle contains default key"] = () =>
                bundle.GroupBundles.ContainsKey("default").is_true();

            it["has no Assets"] () => 
                bundle.GroupBundles["default"].Assets.Count.Is(0);
        };
        
        context["adding one file"] = () =>
        {
            act = () => AddTest1JS();
            
            it["contains the file"] = () => 
                bundle.GroupBundles["default"].Assets.Count.Is(1);
            
            context["adding the same file again"] = () =>
            {
                act = () => AddTest1JS();
                
                it["should still only contain one file"] = () => 
                    bundle.GroupBundles["default"].Assets.Count.Is(1);
            };
        };
    }
}
Source Link
Amir
  • 156
  • 3
Loading