Created
December 31, 2010 02:31
-
-
Save mitchdenny/760641 to your computer and use it in GitHub Desktop.
This is a specification for a basic calculator with the implementation rounded out.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
using MSTestContrib.Specifications; | |
namespace Calculator.Core.Specifications | |
{ | |
[TestClass] | |
[SpecificationDescription("As a user I want to perform mathematical calculations so that my head doesn't hurt.")] | |
public class BasicCalculatorSpecification : Specification | |
{ | |
public BasicCalculator Calculator { get; private set; } | |
[TestMethod] | |
[ScenarioDescription("Add two to a calculator with zero on the accumulator.")] | |
public void AddTwoToACalculatorWithZeroOnTheAccumulator() | |
{ | |
Given("a calculator with zero on the accumulator", CalculatorWithZeroOnTheAccumulator) | |
.When("I add two to the accumulator", x => this.Calculator.Add(2)) | |
.Then("the accumulator should show two", x => this.Calculator.Accumulator == 2); | |
} | |
private void CalculatorWithZeroOnTheAccumulator(SpecificationContext context) | |
{ | |
Calculator = new BasicCalculator(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment