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
namespace CarSellingLib | |
{ | |
public interface IDealer | |
{ | |
Car SellCar(int amount); | |
} | |
} |
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 | |
// 再利用可能な値を定義する |
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
Scenario: When selling a car for 30000 it should equal the DreamCar mocked | |
- As Bert | |
- With Mocking | |
- When selling a car for 30000 | |
=> It should equal BMW (200 HP) | |
=> It should not equal Fiat (45 HP) | |
==> OK |
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
// 定義済みのシナリオ | |
let factorialScenario x result = | |
Given x | |
|> When calculating factorial | |
|> It should equal result | |
[<Scenario>] | |
let When_calculation_factorial_of_1() = | |
factorialScenario 1 1 | |
|> Verify |
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
Scenario: When calculation factorial of 1 – Given 1 | |
– When calculating factorial | |
=> It should equal 1 | |
==> OK | |
==> Time: 0.0093s |
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
// 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 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 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 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 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 |