Creating Booleans With AutoFixture by Mark Seemann
(Just back after 14 days in Morocco, I'll pick up where I left…)
The last group of built-in special creation algorithms for AutoFixture, besides strings and numbers, concerns Booleans.
The default algorithm is to alternate between true and false, starting with true; i.e. the first time you invoke
fixture.CreateAnonymous<bool>();
it will return true, the next time false, then true again, etc.
The reason I chose this algorithm was because I wanted to ensure that the first time AutoFixture creates an anonymous Boolean, it will return true, which is different than the default (false, in case you were in doubt). This gives us better assurance that a given constructor argument or property is being assigned a real value instead of the default.
Like with numbers, using the overload that takes a seed has no effect, and the seed is simply ignored.
fixture.CreateAnonymous(true);
In other words, the above method is still going to return false every second time, so it doesn't really make sense to use this overload at all for Booleans (or numbers).