Exemplo n.º 1
0
        /// <summary>
        /// Processes creating web test resources.
        /// </summary>
        /// <param name="options"><see cref="CommandBuildOptions"/> instance.</param>
        /// <returns>Returns <c>True</c>; if processed successfully; otherwise returns <c>False</c>.</returns>
        public async Task <bool> ProcessAsync(CommandBuildOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            return(await this.ProcessAsync(options.Name, options.Url, options.AuthType, options.AccessToken, options.TestType).ConfigureAwait(false));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Executes the console application.
        /// </summary>
        /// <param name="args">List of arguments.</param>
        public static void Main(string[] args)
        {
            Console.WriteLine("Web Test Generator for Azure Application Insights");
            Console.WriteLine();

            CommandBuildOptions options;

            try
            {
                options = CommandBuildOptions.Build(args);
            }
            catch
            {
                Console.WriteLine(CommandBuildOptions.GetUsage());
#if DEBUG
                Console.WriteLine("Press any key to complete the process");
                Console.ReadLine();
#endif
                return;
            }

            Console.WriteLine("Processing started ...");

            using (var settings = WebTestSettingsElement.CreateInstance())
                using (var context = new AuthenticationContextWrapper($"{settings.Authentication.AadInstanceUrl.TrimEnd('/')}/{settings.Authentication.TenantName}.onmicrosoft.com", false))
                    using (var service = new WebTestService(settings, context))
                    {
                        try
                        {
                            var processed = service.ProcessAsync(options).Result;
                        }
                        catch (AggregateException ex)
                        {
                            foreach (var e in ex.InnerExceptions)
                            {
                                Console.WriteLine($"--- Exception #{ex.InnerExceptions.IndexOf(e) + 1} ---");
                                LogErrorToConsole(e);
                            }
                        }
                        catch (Exception ex)
                        {
                            LogErrorToConsole(ex);
                        }
                    }

            Console.WriteLine("Processing completed");
#if DEBUG
            Console.WriteLine("Press any key to complete the process");
            Console.ReadLine();
#endif
        }