コード例 #1
0
        public static AppRunnerResult RunInMem <T>(
            this AppRunner <T> runner,
            string[] args,
            ITestOutputHelper testOutputHelper,
            IEnumerable <object> dependencies = null) where T : class
        {
            var consoleOut = new TestConsoleWriter(testOutputHelper);

            runner.OverrideConsoleOut(consoleOut);
            runner.OverrideConsoleError(consoleOut);

            var resolver = new TestDependencyResolver();

            foreach (var dependency in dependencies ?? Enumerable.Empty <object>())
            {
                resolver.Register(dependency);
            }
            runner.UseDependencyResolver(resolver);

            var outputs = new TestOutputs();

            resolver.Register(outputs);

            var exitCode = runner.Run(args);

            return(new AppRunnerResult(exitCode, consoleOut.ToString(), outputs));
        }