visit
We continue our adventure trying to solve the Diamond Kata while using Property-Based testing. Last time, we added our first test, Non-empty, and discovered how to use input generators. Now let's figure out the next test.
input: A
A
input: E
----A----
---B-B---
--C---C--
-D-----D-
E-------E
-D-----D-
--C---C--
---B-B---
----A----
[Property(Arbitrary = new[] { typeof(LetterGenerator) })]
public Property FirstLineContainsA(char c)
{
return Diamond.Generate(c).First().Contains('A').ToProperty();
}
[Property(Arbitrary = new[] { typeof(LetterGenerator) })]
public Property LastLineContainsA(char c)
{
return Diamond.Generate(c).Last().Contains('A').ToProperty();
}
If you are wondering what's [Property(Arbitrary = new[] { typeof(LetterGenerator) })] it's probably because you missed my previous
Previously published at