控制台窗口未显示

Pos*_*Guy 1 c# nunit

我在我的一个NUnit测试中有这个.我正在使用R#来完成我的测试.控制台窗口没有弹出来向我显示该foreach循环的内容...不确定我缺少什么但是,有数据要循环通过所以它不像这里没有数据

foreach (PostEntry post in posts)
{
    Console.WriteLine("id: " + post.Id);
    Console.WriteLine("title: " + post.Title);
    Console.WriteLine("body: " + post.Body);
    Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)

wiz*_*rdz 5

如果您正在处理类库并且您只想查看每个循环的内容,可以使用 System.Diagnostics.Debug.Write而不是Console.WriteLine.您可以在" 输出"窗口中看到输出.

foreach (PostEntry post in posts)
{
    System.Diagnostics.Debug.WriteLine("loop starts");
    System.Diagnostics.Debug.WriteLine("id: " + post.Id);
    System.Diagnostics.Debug.WriteLine("title: " + post.Title);
    System.Diagnostics.Debug.WriteLine("body: " + post.Body);
    System.Diagnostics.Debug.WriteLine("loop ends");
    System.Diagnostics.Debugger.Break();
}
Run Code Online (Sandbox Code Playgroud)