예제 #1
0
        public static void Main(string[] args)
        {
            var writter = new ExtendedTextWrapper(Console.Out);

            new AutoRun(typeof(Program).GetTypeInfo().Assembly).Execute(args, writter, Console.In);
            Console.ReadLine();
        }
예제 #2
0
        public void CreateReporter()
        {
            _report = new StringBuilder();
            var writer = new ExtendedTextWrapper(new StringWriter(_report));

            _reporter = new ResultReporter(_result, writer, new ConsoleOptions());
        }
예제 #3
0
 public static int Main(string[] args)
 {
     using (var writter = new ExtendedTextWrapper(Console.Out))
     {
         return(new AutoRun(typeof(TestAmqpUri).GetTypeInfo().Assembly).Execute(args, writter, null));
     }
 }
예제 #4
0
        static void Main(string[] args)
        {
            var writter  = new ExtendedTextWrapper(Console.Out);
            int exitCode = new AutoRun(typeof(Program).GetTypeInfo().Assembly).Execute(args, writter, Console.In);

            Environment.Exit(exitCode);
        }
        /// <summary>
        /// The main program executes the tests. Output may be routed to
        /// various locations, depending on the arguments passed.
        /// </summary>
        /// <remarks>Run with --help for a full list of arguments supported</remarks>
        /// <param name="args"></param>
        public static int Main(string[] args)
        {
            var licenseKey = Environment.GetEnvironmentVariable("SERVICESTACK_LICENSE");

            if (string.IsNullOrEmpty(licenseKey))
            {
                throw new ArgumentNullException("SERVICESTACK_LICENSE", "Add Environment variable for SERVICESTACK_LICENSE");
            }

            Licensing.RegisterLicense(licenseKey);
            //"ActivatedLicenseFeatures: ".Print(LicenseUtils.ActivatedLicenseFeatures());
            LogManager.LogFactory = new ConsoleLogFactory(debugEnabled: true);


            CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
            JsConfig.InitStatics();
            //JsonServiceClient client = new JsonServiceClient();
            var writer = new ExtendedTextWrapper(Console.Out);
            var result = new AutoRun(((IReflectableType)typeof(NetCoreTestsRunner)).GetTypeInfo().Assembly).Execute(args, writer, Console.In);

#if DEBUG
            "Press Any Key to Quit.".Print();
            Console.Read();
#endif
            return(result);
        }
예제 #6
0
        public void MissingFileTest(string filename, string message)
        {
            var fullname = Path.Combine(TestContext.CurrentContext.TestDirectory, filename);

            var services = new ServiceContext();

            services.Add(new InProcessTestRunnerFactory());
            services.Add(new ExtensionService());
            services.Add(new DriverService());
#if NET35
            services.Add(new RuntimeFrameworkService());
#endif

            var package = new TestPackage(fullname);
            package.AddSetting("ProcessModel", "InProcess");
            package.AddSetting("DomainUsage", "None");

            var runner = new MasterTestRunner(services, package);

            var result   = runner.Run(this, TestFilter.Empty);
            var sb       = new StringBuilder();
            var writer   = new ExtendedTextWrapper(new StringWriter(sb));
            var reporter = new ResultReporter(result, writer, new ConsoleOptions());

            reporter.WriteErrorsFailuresAndWarningsReport();
            var report = sb.ToString();

            Assert.That(report, Contains.Substring($"1) Invalid : {fullname}"));
            Assert.That(report, Contains.Substring(message));
        }
        /// <summary>
        /// The main program executes the tests. Output may be routed to
        /// various locations, depending on the arguments passed.
        /// </summary>
        /// <remarks>Run with --help for a full list of arguments supported</remarks>
        /// <param name="args"></param>
        public static int Main(string[] args)
        {
            var licenseKey = Environment.GetEnvironmentVariable("SERVICESTACK_LICENSE");

            if (licenseKey.IsNullOrEmpty())
            {
                throw new ArgumentNullException("SERVICESTACK_LICENSE", "Add Environment variable for SERVICESTACK_LICENSE");
            }

            Licensing.RegisterLicense(licenseKey);
            //"ActivatedLicenseFeatures: ".Print(LicenseUtils.ActivatedLicenseFeatures());

            var postgreSqlDb = Environment.GetEnvironmentVariable("POSTGRESQL_DB");

            if (!String.IsNullOrEmpty(postgreSqlDb))
            {
                Config.PostgreSqlDb = postgreSqlDb;
            }

            CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
            JsConfig.InitStatics();

            //JsonServiceClient client = new JsonServiceClient();
            var writer = new ExtendedTextWrapper(Console.Out);

            return(new AutoRun(((IReflectableType)typeof(NetCoreTestsRunner)).GetTypeInfo().Assembly).Execute(args, writer, Console.In));
        }
예제 #8
0
        public int Execute(string[] args)
        {
            _options = new NUnitLiteOptions(_testAssembly == null, args);

            ExtendedTextWriter outWriter = null;

            if (_options.OutFile != null)
            {
                var outFile    = Path.Combine(_options.WorkDirectory, _options.OutFile);
                var textWriter = TextWriter.Synchronized(new StreamWriter(outFile));
                outWriter = new ExtendedTextWrapper(textWriter);
                Console.SetOut(outWriter);
            }
            else
            {
                outWriter = new ColorConsoleWriter(!_options.NoColor);
            }

            using (outWriter)
            {
                TextWriter errWriter = null;
                if (_options.ErrFile != null)
                {
                    var errFile = Path.Combine(_options.WorkDirectory, _options.ErrFile);
                    errWriter = TextWriter.Synchronized(new StreamWriter(errFile));
                    Console.SetError(errWriter);
                }

                using (errWriter)
                {
                    _textUI = new TextUI(outWriter, Console.In, _options);
                    return(Execute());
                }
            }
        }
예제 #9
0
        private TextUI CreateTextUI(string labelSetting)
        {
            var writer  = new ExtendedTextWrapper(new StringWriter(_reportBuilder));
            var options = new NUnitLiteOptions("--labels:" + labelSetting);

            return(new TextUI(writer, null, options));
        }
예제 #10
0
        public void CreateTextUI()
        {
            _reportBuilder = new StringBuilder();
            var writer  = new ExtendedTextWrapper(new StringWriter(_reportBuilder));
            var options = new NUnitLiteOptions();

            _textUI = new TextUI(writer, null, options);
        }
예제 #11
0
 private static int Main(string[] args)
 {
     using (var writer = new ExtendedTextWrapper(Console.Out))
     {
         return(new AutoRun(Assembly.GetExecutingAssembly())
                .Execute(args, writer, Console.In));
     }
 }
예제 #12
0
        /// <summary>
        /// The main program executes the tests. Output may be routed to
        /// various locations, depending on the arguments passed.
        /// </summary>
        /// <remarks>Run with --help for a full list of arguments supported</remarks>
        /// <param name="args"></param>
        public static int Main(string[] args)
        {
            CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
            JsConfig.InitStatics();
            //JsonServiceClient client = new JsonServiceClient();
            var writer = new ExtendedTextWrapper(Console.Out);

            return(new AutoRun(((IReflectableType)typeof(NetCoreTestsRunner)).GetTypeInfo().Assembly).Execute(args, writer, Console.In));
        }
예제 #13
0
        public int Execute(string[] args)
        {
            var options = new NUnitLiteOptions(args);

            InitializeInternalTrace(options);

            ExtendedTextWriter outWriter = null;

            if (options.OutFile != null)
            {
                var outFile = Path.Combine(options.WorkDirectory, options.OutFile);
#if NETSTANDARD1_6
                var textWriter = File.CreateText(outFile);
#else
                var textWriter = TextWriter.Synchronized(new StreamWriter(outFile));
#endif
                outWriter = new ExtendedTextWrapper(textWriter);
                Console.SetOut(outWriter);
            }
            else
            {
                outWriter = new ColorConsoleWriter();
            }

            TextWriter errWriter = null;
            if (options.ErrFile != null)
            {
                var errFile = Path.Combine(options.WorkDirectory, options.ErrFile);
#if NETSTANDARD1_6
                errWriter = File.CreateText(errFile);
#else
                errWriter = TextWriter.Synchronized(new StreamWriter(errFile));
#endif
                Console.SetError(errWriter);
            }

            try
            {
                return(Execute(outWriter, Console.In, options));
            }
            finally
            {
                if (options.OutFile != null && outWriter != null)
#if NETSTANDARD1_6
                { outWriter.Dispose(); }
#else
                { outWriter.Close(); }
#endif

                if (options.ErrFile != null && errWriter != null)
#if NETSTANDARD1_6
                { errWriter.Dispose(); }
#else
                { errWriter.Close(); }
#endif
            }
        }
예제 #14
0
        public static int Main(string[] args)
        {
#if PCL
            var writer = new ExtendedTextWrapper(Console.Out);
            return(new AutoRun(typeof(Program).GetTypeInfo().Assembly).Execute(args, writer, Console.In));
#else
            return(new AutoRun().Execute(args));
#endif
        }
예제 #15
0
        public void CreateReporter()
        {
            _report = new StringBuilder();

            var writer  = new ExtendedTextWrapper(new StringWriter(_report));
            var options = new ConsoleOptions();

            options.Parse(new string[] { "MockTestResult.xml" });

            _reporter = new ResultReporter(_result, writer, options);
        }
예제 #16
0
        /// <summary>
        /// The main program executes the tests. Output may be routed to
        /// various locations, depending on the arguments passed.
        /// </summary>
        /// <remarks>Run with --help for a full list of arguments supported</remarks>
        /// <param name="args"></param>
        public static int Main(string[] args)
        {
            var writer = new ExtendedTextWrapper(Console.Out);
            var result = new AutoRun(((IReflectableType)typeof(NetCoreTestsRunner)).GetTypeInfo().Assembly).Execute(args, writer, Console.In);

#if DEBUG
            "Press Any Key to Quit.".Print();
            Console.Read();
#endif
            return(result);
        }
예제 #17
0
        public void CreateTextUI()
        {
            _reportBuilder = new StringBuilder();
            var writer = new ExtendedTextWrapper(new StringWriter(_reportBuilder));

#if !SILVERLIGHT && !PORTABLE
            var options = new ConsoleOptions();
            _textUI = new TextUI(writer, options);
#else
            _textUI = new TextUI(writer);
#endif
        }
예제 #18
0
        public static void Main(string[] args)
        {
            var writter = new ExtendedTextWrapper(Console.Out);

            new AutoRun(typeof(Program).GetTypeInfo().Assembly).Execute(args, writter, Console.In);

            Console.ReadKey();

            //IServiceCollection serviceCollection = new ServiceCollection();
            //ConfigureServices(serviceCollection);
            //IServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();
        }
예제 #19
0
        // This is the main entry point of the application.
        static void Main(string[] args)
        {
            // if you want to use a different Application Delegate class from "UnitTestAppDelegate"
            // you can specify it here.
            //UIApplication.Main(args, null, "UnitTestAppDelegate");

            // tests can be inside the main assembly
            //AddTest(Assembly.GetExecutingAssembly());
            //AddTest(typeof(ClientTest.JsonServiceClientTests).Assembly);
            // or in any reference assemblies
            // AddTest (typeof (Your.Library.TestClass).Assembly);
            var writer = new ExtendedTextWrapper(Console.Out);
            var result = new AutoRun(typeof(ClientTest.Tests.JsonServiceClientTests).Assembly).Execute(new[] { "--labels=All", "--teamcity" }, writer, Console.In);
        }
        /// <summary>
        /// The main program executes the tests. Output may be routed to
        /// various locations, depending on the arguments passed.
        /// </summary>
        /// <remarks>Run with --help for a full list of arguments supported</remarks>
        /// <param name="args"></param>
        public static int Main(string[] args)
        {
            var licenseKey = Environment.GetEnvironmentVariable("SERVICESTACK_LICENSE");

            if (licenseKey.IsNullOrEmpty())
            {
                throw new ArgumentNullException("SERVICESTACK_LICENSE", "Add Environment variable for SERVICESTACK_LICENSE");
            }

            Licensing.RegisterLicense(licenseKey);
            //"ActivatedLicenseFeatures: ".Print(LicenseUtils.ActivatedLicenseFeatures());

            var sqlServerBuildDb = Environment.GetEnvironmentVariable("SQL_SERVER_BUILD_DB");

            if (!String.IsNullOrEmpty(sqlServerBuildDb))
            {
                Config.SqlServerBuildDb  = sqlServerBuildDb;
                Config.DefaultConnection = Config.SqlServerBuildDb;
            }

            var postgreSqlDb = Environment.GetEnvironmentVariable("POSTGRESQL_DB");

            if (!String.IsNullOrEmpty(postgreSqlDb))
            {
                Config.PostgreSqlDb = postgreSqlDb;
            }

            var dialect = Environment.GetEnvironmentVariable("ORMLITE_DIALECT");

            if (!String.IsNullOrEmpty(dialect))
            {
                Dialect defaultDialect;

                if (Enum.TryParse(dialect, out defaultDialect))
                {
                    Config.DefaultDialect = defaultDialect;
                }
            }

            Console.WriteLine($"Dialect: {Config.DefaultDialect}");

            CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US");
            JsConfig.InitStatics();

            //JsonServiceClient client = new JsonServiceClient();
            var writer = new ExtendedTextWrapper(Console.Out);

            return(new AutoRun(((IReflectableType)typeof(NetCoreTestsRunner)).GetTypeInfo().Assembly).Execute(args, writer, Console.In));
        }
예제 #21
0
        private void RunTests(Assembly assembly)
        {
            StringBuilder sb      = new StringBuilder();
            string        dllName = assembly.ManifestModule.ToString();

            using (ExtendedTextWrapper writer = new ExtendedTextWrapper(new StringWriter(sb)))
            {
                string[] finalNunitArgs = nunitArgs.Concat(new string[]
                                                           { "--result=/tmp/" + Path.GetFileNameWithoutExtension(dllName) + ".xml", "--work=/tmp" }).ToArray();
                new AutoRun(assembly).Execute(finalNunitArgs, writer, Console.In);
            }

            foreach (var line in sb.ToString().Split("\n"))
            {
                Logger.Info(line);
            }
        }
예제 #22
0
        protected override void OnCreate(Bundle bundle)
        {
            // tests can be inside the main assembly
            //AddTest(Assembly.GetExecutingAssembly());
            //AddTest(typeof(ClientTest.JsonServiceClientTests).Assembly);
            // or in any reference assemblies
            // AddTest (typeof (Your.Library.TestClass).Assembly);


            // Once you called base.OnCreate(), you cannot add more assemblies.
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);
            var txtOutput = (TextView)FindViewById(Resource.Id.txtOutput);

            var writer = new ExtendedTextWrapper(new MultiTextWriter(new TextViewWriter(txtOutput), Console.Out));
            var result = new AutoRun(typeof(ClientTest.Tests.JsonServiceClientTests).Assembly).Execute(new[] { "--labels=All", "--teamcity" }, writer, Console.In);
        }
예제 #23
0
        public int Execute(string[] args)
        {
            var options = new NUnitLiteOptions(args);

            InitializeInternalTrace(options);

            ExtendedTextWriter outWriter = null;

            if (options.OutFile != null)
            {
                outWriter = new ExtendedTextWrapper(new StreamWriter(Path.Combine(options.WorkDirectory, options.OutFile)));
                Console.SetOut(outWriter);
            }
            else
            {
                outWriter = new ColorConsoleWriter();
            }

            TextWriter errWriter = null;

            if (options.ErrFile != null)
            {
                errWriter = new StreamWriter(Path.Combine(options.WorkDirectory, options.ErrFile));
                Console.SetError(errWriter);
            }

            try
            {
                return(Execute(outWriter, Console.In, options));
            }
            finally
            {
                if (options.OutFile != null && outWriter != null)
                {
                    outWriter.Close();
                }

                if (options.ErrFile != null && errWriter != null)
                {
                    errWriter.Close();
                }
            }
        }
예제 #24
0
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used such as when the application is launched to open a specific file.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                rootFrame.NavigationFailed += OnNavigationFailed;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    //TODO: Load state from previously suspended application
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            //Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.CreateDefaultUI();

            // Ensure the current window is active
            Window.Current.Activate();

            var writer = new ExtendedTextWrapper(new DebugTextWriter());
            var result = new AutoRun(typeof(ClientTest.Tests.JsonServiceClientTests).Assembly).Execute(new[] { "--labels=All", "--teamcity" }, writer, Console.In);

            // Microsoft.VisualStudio.TestPlatform.TestExecutor.UnitTestClient.Run(e.Arguments);
        }
예제 #25
0
 public void SetUp()
 {
     sb     = new StringBuilder();
     writer = new ExtendedTextWrapper(new StringWriter(sb));
 }
예제 #26
0
 public void SetUp()
 {
     sb = new StringBuilder();
     writer = new ExtendedTextWrapper(new StringWriter(sb));
 }
예제 #27
0
        /// <summary>
        /// Execute the tests in the assembly, passing in
        /// a list of arguments.
        /// </summary>
        /// <param name="args">Execution options</param>
        public int Execute(string[] args)
        {
            var options         = new ConsoleOptions(args);
            var callingAssembly = Assembly.GetCallingAssembly();

            var level = (InternalTraceLevel)Enum.Parse(typeof(InternalTraceLevel), options.InternalTraceLevel ?? "Off", true);

#if NETCF  // NETCF: Try to unify
            InitializeInternalTrace(callingAssembly.GetName().CodeBase, level);
#else
            InitializeInternalTrace(callingAssembly.Location, level);
#endif

            ExtendedTextWriter outWriter = null;
            if (options.OutFile != null)
            {
                outWriter = new ExtendedTextWrapper(new StreamWriter(Path.Combine(options.WorkDirectory, options.OutFile)));
                Console.SetOut(outWriter);
            }

            TextWriter errWriter = null;
            if (options.ErrFile != null)
            {
                errWriter = new StreamWriter(Path.Combine(options.WorkDirectory, options.ErrFile));
                Console.SetError(errWriter);
            }

            var _textUI = new TextUI(outWriter, options);

            if (!options.NoHeader)
            {
                _textUI.DisplayHeader();
            }

            if (options.ShowHelp)
            {
                _textUI.DisplayHelp();
                return(TextRunner.OK);
            }

            if (options.ErrorMessages.Count > 0)
            {
                _textUI.DisplayErrors(options.ErrorMessages);
                _textUI.DisplayHelp();

                return(TextRunner.INVALID_ARG);
            }

            if (options.InputFiles.Count > 0)
            {
                _textUI.DisplayError("Input assemblies may not be specified when using the NUnitLite AutoRunner");
                return(TextRunner.INVALID_ARG);
            }

            _textUI.DisplayTestFiles(new string[] { callingAssembly.GetName().Name });
            _textUI.DisplayRuntimeEnvironment();
            _textUI.DisplayRequestedOptions();

            if (options.WaitBeforeExit && options.OutFile != null)
            {
                _textUI.DisplayWarning("Ignoring /wait option - only valid for Console");
            }

            try
            {
                return(new TextRunner(_textUI, options).Execute(callingAssembly));
            }
            finally
            {
                if (options.WaitBeforeExit)
                {
                    _textUI.WaitForUser("Press Enter key to continue . . .");
                }

                if (outWriter != null)
                {
                    outWriter.Close();
                }

                if (errWriter != null)
                {
                    errWriter.Close();
                }
            }
        }