コード例 #1
0
            public void ConsoleIsRedirected()
            {
                var assemblyPathName = Path.Combine(Environment.CurrentDirectory, "..\\..\\..\\..\\build\\Debug\\ConsoleRedirection.dll");

                using (var recipe = RecipeFactory.NewRecipe(string.Empty)) {
                    var temporarilyStoredConsoleOut = Console.Out;
                    Console.SetOut(MyConsole);
                    recipe.SetConsoleOutputTo(MyConsole);
                    recipe.AddAssembly(assemblyPathName);
                    recipe.RunTests(new TestRun(new AllTestsCriterion()));
                    recipe.Join();
                    Console.SetOut(temporarilyStoredConsoleOut);
                }

                Assert.Contains("Show me the list:" + MyConsole.NewLine + "A" + MyConsole.NewLine
                                + "B" + MyConsole.NewLine + "C" + MyConsole.NewLine + "# end of list #" + MyConsole.NewLine,
                                MyConsole.GetStringBuilder().ToString());
            }