<commit_before><h1 align="center"><img src="https://raw.github.com/trackabout/speceasy/master/speceasy_logo.png" alt="SpecEasy" height="85"></h1>

SpecEasy is a BDD-based unit testing framework that allows you to easily and quickly write tests using a fluid interface that reduces the amount of code needed to create tests.

## What does SpecEasy require?

SpecEasy is currently built on and requires the NUnit test framework. If you're using NUnit, then it's as simple as:

1. [Install SpecEasy using NuGet][NuGet]
2. Start writing specs the easy way!

SpecEasy also uses [RhinoMocks][] and [NUnit][]; these dependencies will be installed via NuGet if needed.

## A note on versions
There are currently two major versions of SpecEasy available on NuGet:

* Version 1.0.0 - Targets .NET 3.5 or higher
* Version 2.0.0 - Targets .NET 4.5.1 or higher and supports testing async methods

At this time, active development is only planned for the 2.0.0 version unless some significant feature is needed for projects targeting .NET 3.5 or 4.0.

## Quickstart Guide

* Inherit from `Spec<T>`, where T is the type you want to test. SpecEasy give you access to an instance of T through a base variable called SUT (System Under Test), and automatically new it up on demand.
* No need to decorate your code with test attributes. `Spec<T>` handles that for you.
* Use `When(string, Action)` to test what you want to test (Action).
* Use `Given(string, Action).Verify(Action)` for set up code (Arrange).
* Use `Then(string, Action)` to verify the results (Assert).
* Nest `Given(string Action)` method calls to handle more complicated set up.
* Use `Set<T>(T)` to set dependencies that will be injected into your SUT.
* Use `Get<T>()` to get access to dependencies automatically created for your SUT. Chain calls to `Get<T>()` with calls to `Stub<T>(Action)` to set up mocks for dependencies.
* Use `AssertWasCalled<T>(Action)` and `AssertWasNotCalled<T>(Action)` to check if methods or properties were called on dependencies.
 
## Going a bit deeper

Let's use FizzBuzz as a sample implementation to test. As a reminder, the rules for FizzBuzz are as follows:

* The method should take in a number and return a string
* For most numbers, return the string value for that number, i.e., 1 returns "1"
* For multiples of 3, it should return "fizz"
* For multiples of 5, it should return "buzz"
* For multiples of 3 and 5, it should return "fizzbuzz"

We'll start out with a base FizzBuzz implementation:

    public class FizzBuzz 
    {
        public string Do(int number) 
        {
            return "";
        } 
    }

Let's get started writing specs.

### 1.) Inherit from Spec

    public class FizzBuzzpecs : SpecEasy.Spec<FizzBuzz> { }

### 2.) Test the simplest case first

SpecEasy doesn't require that you decorate your code with attributes to run tests. It uses  Given/When/Then syntax, and every call to Then will result in a test being run. The first step to check if I pass in 1, does it return "1".

    public void FizzBuzzDo()
    {
        string result = string.Empty;
        int input = 0;

        When("running FizzBuzz", () => result = SUT.Do(input));
<commit_msg>Fixed missing character in class name<commit_after><h1 align="center"><img src="https://raw.github.com/trackabout/speceasy/master/speceasy_logo.png" alt="SpecEasy" height="85"></h1>

SpecEasy is a BDD-based unit testing framework that allows you to easily and quickly write tests using a fluid interface that reduces the amount of code needed to create tests.

## What does SpecEasy require?

SpecEasy is currently built on and requires the NUnit test framework. If you're using NUnit, then it's as simple as:

1. [Install SpecEasy using NuGet][NuGet]
2. Start writing specs the easy way!

SpecEasy also uses [RhinoMocks][] and [NUnit][]; these dependencies will be installed via NuGet if needed.

## A note on versions
There are currently two major versions of SpecEasy available on NuGet:

* Version 1.0.0 - Targets .NET 3.5 or higher
* Version 2.0.0 - Targets .NET 4.5.1 or higher and supports testing async methods

At this time, active development is only planned for the 2.0.0 version unless some significant feature is needed for projects targeting .NET 3.5 or 4.0.

## Quickstart Guide

* Inherit from `Spec<T>`, where T is the type you want to test. SpecEasy give you access to an instance of T through a base variable called SUT (System Under Test), and automatically new it up on demand.
* No need to decorate your code with test attributes. `Spec<T>` handles that for you.
* Use `When(string, Action)` to test what you want to test (Action).
* Use `Given(string, Action).Verify(Action)` for set up code (Arrange).
* Use `Then(string, Action)` to verify the results (Assert).
* Nest `Given(string Action)` method calls to handle more complicated set up.
* Use `Set<T>(T)` to set dependencies that will be injected into your SUT.
* Use `Get<T>()` to get access to dependencies automatically created for your SUT. Chain calls to `Get<T>()` with calls to `Stub<T>(Action)` to set up mocks for dependencies.
* Use `AssertWasCalled<T>(Action)` and `AssertWasNotCalled<T>(Action)` to check if methods or properties were called on dependencies.
 
## Going a bit deeper

Let's use FizzBuzz as a sample implementation to test. As a reminder, the rules for FizzBuzz are as follows:

* The method should take in a number and return a string
* For most numbers, return the string value for that number, i.e., 1 returns "1"
* For multiples of 3, it should return "fizz"
* For multiples of 5, it should return "buzz"
* For multiples of 3 and 5, it should return "fizzbuzz"

We'll start out with a base FizzBuzz implementation:

    public class FizzBuzz 
    {
        public string Do(int number) 
        {
            return "";
        } 
    }

Let's get started writing specs.

### 1.) Inherit from Spec

    public class FizzBuzzSpecs : SpecEasy.Spec<FizzBuzz> { }

### 2.) Test the simplest case first

SpecEasy doesn't require that you decorate your code with attributes to run tests. It uses  Given/When/Then syntax, and every call to Then will result in a test being run. The first step to check if I pass in 1, does it return "1".

    public void FizzBuzzDo()
    {
        string result = string.Empty;
        int input = 0;

        When("running FizzBuzz", () => result = SUT.Do(input));

{'fraction_non_alphanumeric': 0.08433923812509798, 'fraction_numerical': 0.010973506819250666, 'mean_word_length': 3.7969924812030076, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 29, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5035287', 'n_tokens_mistral': 1898, 'n_tokens_neox': 1801, 'n_words': 911}