Skip to content

Instantly share code, notes, and snippets.

@posaunehm
Created December 7, 2012 14:26
Show Gist options
  • Select an option

  • Save posaunehm/4233567 to your computer and use it in GitHub Desktop.

Select an option

Save posaunehm/4233567 to your computer and use it in GitHub Desktop.
for F# advent calender 2012
// C#のオブジェクトを作る
let sut () =
let vm = new VendingMachine(new StandardMoneyAcceptor())
vm.SetDrinkSpecification([new PriceSpecification("Cola",110); new PriceSpecification("Soda",150)])
vm
// 受け取ったオブジェクトに操作を行い、操作後のオブジェクトを返却する。
let insert_money amount (vm:VendingMachine) =
printMethod amount
amount |> List.iter vm.InsertMoney
vm
//TotalAmountプロパティを比較するヘルパメソッド
let total_amount amount (vm:VendingMachine) =
printMethod amount
vm.TotalAmount = amount
//Feature:お金が投入できる
[<Scenario>]
let ``After inserting 10 yen, it's total amount is 10``() =
Given sut ()
|> When insert_money [new Money(MoneyKind.Yen10)]
|> It should have (total_amount 10)
|> Verify
[<Scenario>]
let ``After inserting 10 yen and 100 yen, it's total amount is 110``() =
Given sut ()
|> When insert_money [new Money(MoneyKind.Yen10);new Money(MoneyKind.Yen100)]
|> It should have (total_amount 110)
|> Verify
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment