Created
August 26, 2012 06:16
-
-
Save smallgeek/3474948 to your computer and use it in GitHub Desktop.
NaturalSpec_Tutorial_3_3
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
// 1. モジュールを定義する | |
module CarSpec | |
// 2. NaturalSpec 名前空間を開く | |
open NaturalSpec | |
// 3. プロジェクトの名前空間を開く | |
open CarSellingLib | |
// 4. テストコンテキストを定義する | |
let Bert = new Dealer("Bert") | |
// 再利用可能な値を定義する | |
let DreamCar = new Car(CarType.BMW, 200) | |
let LameCar = new Car(CarType.Fiat, 45) | |
// 5. BDDスタイルでメソッドを生成する | |
let selling_a_car_for amount (dealer:Dealer) = | |
printMethod amount | |
dealer.SellCar amount | |
// 6. シナリオを作成する | |
[<Scenario>] | |
let When_selling_a_car_for_30000_it_should_equal_the_DreamCar() = | |
As Bert | |
|> When selling_a_car_for 30000 | |
|> It should equal DreamCar | |
|> It shouldn't equal LameCar | |
|> Verify | |
[<Scenario>] | |
let When_selling_a_car_for_19000_it_should_equal_the_LameCar() = | |
As Bert | |
|> When selling_a_car_for 19000 | |
|> It should equal LameCar | |
|> It shouldn't equal DreamCar | |
|> Verify | |
// エラーを想定したシナリオを作成する | |
[<Scenario>] | |
[<FailsWith "Need more money">] | |
let When_selling_a_car_for_1000_it_should_fail_with_Need_More_Money() = | |
As Bert | |
|> When selling_a_car_for 1000 | |
|> Verify |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment