Ejemplo n.º 1
0
        private static int Main(string[] args)
        {
            try
            {
                _chalk = new Chalk();
                Trace.Listeners.Add(new EventLogTraceListener("MuTest_CPP_CLI"));

                _muTest = new MuTestRunner(_chalk, new CppDirectoryFactory());
                var app = new MuTestCli(_muTest);

                CancelKeyPress += CancelMutationHandler;
                AppDomain.CurrentDomain.ProcessExit += CancelMutationHandler;

                return(app.Run(args));
            }
            catch (MuTestInputException ex)
            {
                ShowMessage(ex);
                CancelMutation();
                return(1);
            }
            catch (CommandParsingException ex)
            {
                _chalk.Red(ex.Message);
                CancelMutation();
                return(1);
            }
            catch (Exception ex)
            {
                CancelMutation();
                var innerException = ex.InnerException;
                if (innerException != null && (innerException.GetType() == typeof(MuTestInputException) ||
                                               innerException.GetType().BaseType == typeof(MuTestInputException)))
                {
                    ShowMessage((MuTestInputException)innerException);

                    var statusCode = MuTestExceptions[innerException.GetType()];
                    _chalk.Red($"\nStatus Code: {statusCode}\n");
                    return(statusCode);
                }

                if (ex.Message.StartsWith("Unrecognized option"))
                {
                    _chalk.Default($"{ex.Message}{Environment.NewLine}");
                    return(1);
                }

                Trace.TraceError("{0}", ex);
                _chalk.Red($"\n{ex.Message} - review trace for more details\n");
                return(1);
            }
        }
Ejemplo n.º 2
0
        private static int Main(string[] args)
        {
            try
            {
                _chalk = new Chalk();
                Trace.Listeners.Add(new EventLogTraceListener("MuTest_CPP_CLI"));
                var services = new ServiceCollection();

                services
                .AddHttpClient <IFirebaseApiClient, FirebaseApiClient>()
                .AddPolicyHandler(GetRetryPolicy())
                .AddPolicyHandler(GetCircuitBreakerPatternPolicy());
                services.AddSingleton(_chalk);
                var provider = services.BuildServiceProvider();
                var factory  = provider.GetService <IHttpClientFactory>();

                _muTest = new MuTestRunner(
                    _chalk,
                    new CppDirectoryFactory(),
                    new FirebaseApiClient(
                        factory.CreateClient(),
                        MuTestSettings.FireBaseDatabaseApiUrl,
                        MuTestSettings.FireBaseStorageApiUrl));
                var app = new MuTestCli(_muTest);

                CancelKeyPress += CancelMutationHandler;
                AppDomain.CurrentDomain.ProcessExit += CancelMutationHandler;

                return(app.Run(args));
            }
            catch (MuTestInputException ex)
            {
                ShowMessage(ex);
                CancelMutation();
                return(1);
            }
            catch (CommandParsingException ex)
            {
                _chalk.Red(ex.Message);
                CancelMutation();
                return(1);
            }
            catch (Exception ex)
            {
                CancelMutation();
                var innerException = ex.InnerException;
                if (innerException != null && (innerException.GetType() == typeof(MuTestInputException) ||
                                               innerException.GetType().BaseType == typeof(MuTestInputException)))
                {
                    ShowMessage((MuTestInputException)innerException);

                    var statusCode = MuTestExceptions[innerException.GetType()];
                    _chalk.Red($"\nStatus Code: {statusCode}\n");
                    return(statusCode);
                }

                if (ex.Message.StartsWith("Unrecognized option"))
                {
                    _chalk.Default($"{ex.Message}{Environment.NewLine}");
                    return(1);
                }

                Trace.TraceError("{0}", ex);
                _chalk.Red($"\n{ex.Message} - review trace for more details\n");
                return(1);
            }
        }