Created
December 7, 2012 14:26
-
-
Save posaunehm/4233567 to your computer and use it in GitHub Desktop.
for F# advent calender 2012
This file contains hidden or 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
| // 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