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
| module Tree = | |
| // (int -> 'a option -> 'b -> 'a -> 'b) -> ('a -> 'a list) -> 'b -> 'a -> 'b | |
| let foldDepthParent folder getChildren state item = | |
| let rec recurse depth parent state item = | |
| let state = folder depth parent state item | |
| match getChildren item with | |
| | [] -> state | |
| | xs -> List.fold (fun acc ch -> recurse (depth + 1) (Some item) acc ch) state xs | |
| recurse 0 None state item |
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
| type Tree = | |
| { Id : string | |
| Branches : Tree 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
| type FolderDto = | |
| { Name : string | |
| ParentId : string } |
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
| +- root-folder | |
| +- sub-folder #1 | |
| +- sub-folder #2 | |
| |- sub-folder #2.1 | |
| +- sub-folder #2.2 | |
| |- sub-folder #2.2.1 | |
| +- sub-folder #3 |
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
| type Folder = | |
| { Name : string | |
| SubFolders : Folder 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
| [Fact] | |
| public void Potato_InSandySoilWithFrequentWatering_Grows() | |
| { | |
| var context = PlantTestContext.GivenPotato(); | |
| context.WhenSoil(SoilType.Sandy); | |
| context.WhenWaterFrequency(TimeSpan.FromDays(1)); | |
| context.ShouldGrow(); | |
| } |
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
| [Fact] | |
| public void Potato_Grows() | |
| { | |
| var plantProvider = new PlantProvider(Logger); | |
| PlantType plantType = plantProvider.GetPlantType(PlantType.Potato); | |
| var context = PlantTestContext.Given(plantType); | |
| var soilRepository = new SoilRepository(context.Configuration, Logger); | |
| var drySoil = soilRepository.GetSoil(SoleType.Sandy); |
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
| [Fact] | |
| public void Potato_DailyShadySunlight_Grows() | |
| { | |
| var context = PlantTestContext.GivenPotato(); | |
| context.WhenDailySunlight(Sunlight.Shady); | |
| context.ShouldGrow(); | |
| } |
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
| [Fact] | |
| public void Potato_DailyShadySunlight_Grows() | |
| { | |
| var context = PlantTestContext.GivenPotato(); | |
| context.WhenDailyShadySunlight(); | |
| context.ShouldGrow(); | |
| } |
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
| public class MyTestContext | |
| { | |
| private readonly Arg<string> _tag = Arg.String.Default(Gen.Tag.Generate()); | |
| private readonly Arg<DateTimeOffset> _before = Arg.Date.Ignore(); | |
| public static MyTestContext Given() | |
| { | |
| return new MyTestContext(); | |
| } |