Skip to content

Instantly share code, notes, and snippets.

@denmerc
Last active March 16, 2016 18:12
Show Gist options
  • Save denmerc/9c1a582db3e450c811d5 to your computer and use it in GitHub Desktop.
Save denmerc/9c1a582db3e450c811d5 to your computer and use it in GitHub Desktop.
f# bdd testing without framework
open NUnit.Framework
type Calculator() =
member __.Add x y = x + y
let ``Given I have entered`` firstNumber continuation =
let calculator = Calculator()
continuation (firstNumber, calculator)
let ``into the calculator`` (state,calculator) continuation =
continuation (state, calculator)
let ``And I have entered`` (firstNumber, calculator) secondNumber continuation =
continuation ((firstNumber, secondNumber), calculator)
let ``When I press add`` ((firstNumber, secondNumber), calculator:Calculator) continuation =
let actual = calculator.Add firstNumber secondNumber
continuation actual
let ``Then the result should be`` actual (expected:int) continuation =
Assert.AreEqual(expected, actual)
continuation
let ``on the screen`` = ()
[<Test>]
let testAdd ()=
``Given I have entered`` 50 ``into the calculator``
``And I have entered`` 70 ``into the calculator``
``When I press add``
``Then the result should be`` 120 ``on the screen``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment