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
| using System; | |
| using Android.App; | |
| using Android.Content; | |
| using Android.Runtime; | |
| using Android.Views; | |
| using Android.Widget; | |
| using Android.OS; | |
| namespace FsAndroid1 |
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
| Scenario: When sorting empty list | |
| - Given [] | |
| – When sorting with QuickSort | |
| => It should be sorted | |
| => It should contain all elements from [] | |
| => It should contain no other elements than [] | |
| ==> Result is: [] | |
| ==> OK | |
| ==> Time: 0.0355s |
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
| /// クイックソートの単純な実装 – 真似しないように | |
| let rec quicksort = function | |
| | [] -> [] | |
| | pivot :: rest -> | |
| let small,big = List.partition ((>) pivot) rest | |
| quicksort small @ [pivot] @ quicksort big | |
| let QuickSort x = | |
| printMethod "" | |
| quicksort x |
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
| [<Scenario>] | |
| let When_sorting_empty_list() = | |
| quicksortScenario [] | |
| |> Verify | |
| [<Scenario>] | |
| let When_sorting_small_list() = | |
| quicksortScenario [2;1;8;15;5;22] | |
| |> Verify |
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
| /// 事前に定義されたソートのシナリオ | |
| let sortingScenario f list = | |
| Given list | |
| |> When sorting_with f | |
| |> It should be sorted | |
| |> It should contain_all_elements_from list | |
| |> It should contain_no_other_elements_than list | |
| /// 事前に定義されたクイックソートのシナリオ | |
| let quicksortScenario list = sortingScenario QuickSort list |
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
| let dividing_by a b = b / a | |
| [<ScenarioSource "MyTestCases">] | |
| let ``When dividing`` a b result = | |
| Given a | |
| |> When dividing_by b | |
| |> It should equal result | |
| |> Verify |
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
| /// シナリオのソースを使用する | |
| let MyTestCases = | |
| TestWith (tripleParam 12 3 4) | |
| |> And (tripleParam 12 4 3) | |
| |> And (tripleParam 12 6 2) | |
| |> And (tripleParam 0 0 0) | |
| |> ShouldFailWith (typeof<System.DivideByZeroException>) | |
| |> And (tripleParam 1200 40 30) |
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
| // ScenarioTemplate 属性を使う | |
| [<ScenarioTemplate(1, 1)>] | |
| [<ScenarioTemplate(2, 2)>] | |
| [<ScenarioTemplate(5, 120)>] | |
| [<ScenarioTemplate(10, 3628800)>] | |
| let When_calculating_fac_(x,result) = | |
| Given x | |
| |> When calculating factorial | |
| |> It should equal result | |
| |> Verify |
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
| Scenario: When calculation factorial of 1 – Given 1 | |
| – When calculating factorial | |
| => It should equal 1 | |
| ==> OK | |
| ==> Time: 0.0093s |
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
| // 定義済みのシナリオ | |
| let factorialScenario x result = | |
| Given x | |
| |> When calculating factorial | |
| |> It should equal result | |
| [<Scenario>] | |
| let When_calculation_factorial_of_1() = | |
| factorialScenario 1 1 | |
| |> Verify |