Check out this test:
[TestFixture]
public class Quick_test
{
[Test]
public void Test()
{
Assert.AreEqual(0, GetByYield().Count());
Assert.AreEqual(0, GetByEnumerable().Count());
}
private IEnumerable<string> GetByYield()
{
yield break;
}
private IEnumerable<string> GetByEnumerable()
{
return Enumerable.Empty<string>();
}
}
When I write stub methods I generally use the Enumerable.Empty way of doing it. I stumbled across some old code I wrote where I did it the yield way.
This got me to wondering:
- Which is more visually appealing to other developers?
- Are there any hidden gotchas that would cause us to prefer one over the other?
Thanks!