In the tests below, I cannot get Console.WriteLine to actually print when using return returns. I am experimenting with the return of profitability, and I understand that I have something missing in my understanding of this, but I can not understand what it is. Why aren't PrintAllYield lines printed?
code:
class Misc1 { public IEnumerable<string> PrintAllYield(IEnumerable<string> list) { foreach(string s in list) { Console.WriteLine(s);
Test:
[TestFixture] class MiscTests { [Test] public void YieldTest() { string[] list = new[] { "foo", "bar" }; Misc1 test = new Misc1(); Console.WriteLine("Start PrintAllYield"); test.PrintAllYield(list); Console.WriteLine("End PrintAllYield"); Console.WriteLine(); Console.WriteLine("Start PrintAll"); test.PrintAll(list); Console.WriteLine("End PrintAll"); } }
Output:
Start PrintAllYield End PrintAllYield Start PrintAll foo bar End PrintAll 1 passed, 0 failed, 0 skipped, took 0,39 seconds (NUnit 2.5.5).
source share