Skip to content

Instantly share code, notes, and snippets.

View stijnmoreels's full-sized avatar
🧪
Testing better than yesterday

Stijn Moreels stijnmoreels

🧪
Testing better than yesterday
View GitHub Profile
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
type Tree =
{ Id : string
Branches : Tree list }
type FolderDto =
{ Name : string
ParentId : string }
+- root-folder
+- sub-folder #1
+- sub-folder #2
|- sub-folder #2.1
+- sub-folder #2.2
|- sub-folder #2.2.1
+- sub-folder #3
type Folder =
{ Name : string
SubFolders : Folder list }
[Fact]
public void Potato_InSandySoilWithFrequentWatering_Grows()
{
var context = PlantTestContext.GivenPotato();
context.WhenSoil(SoilType.Sandy);
context.WhenWaterFrequency(TimeSpan.FromDays(1));
context.ShouldGrow();
}
[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);
[Fact]
public void Potato_DailyShadySunlight_Grows()
{
var context = PlantTestContext.GivenPotato();
context.WhenDailySunlight(Sunlight.Shady);
context.ShouldGrow();
}
[Fact]
public void Potato_DailyShadySunlight_Grows()
{
var context = PlantTestContext.GivenPotato();
context.WhenDailyShadySunlight();
context.ShouldGrow();
}
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();
}