Skip to content


Subversion checkout URL

You can clone with
Download ZIP

Automocking Specification With No Contract

amirci edited this page · 8 revisions

Writing a base specification is very simple, please make sure you read the Introduction.

Let's imagine we have a Calculator class that we want to test

public class Calculator

Let's declare the base class for all the scenarios:

public class CalculatorSpecification 
    : AutomockingSpecificationWithNoContract<Calculator> 

By using this base class we get all the benefits from AutoMockingSpecification, the only difference is that the concrete class and the contract are the same.

So, we are ready to write our first scenario:

public class When_calculator_adds_two_numbers : CalculatorSpecification

So let's review our scenario using Given, When, Then style:

  • Given (nothing)
  • When I add 2 + 3
  • Then I should obtain 5

So let's put in code (remember we don't need Given because there is no condition to check):

protected void WhenIRun() 
   this._actual = this.Sut.Add(2, 3);

public void Should_return_the_addition()
Something went wrong with that request. Please try again.