public void Given_NullParameter_Constructor_ShouldThrow_Exception()
        {
            Action action = () => { var service = new WebTestService(null, this._authContext.Object); };

            action.ShouldThrow <ArgumentNullException>();

            action = () => { var service = new WebTestService(this._settings.Object, null); };
            action.ShouldThrow <ArgumentNullException>();
        }
Пример #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
        }
        public void Given_Parameter_Constructor_ShouldThrow_NoException()
        {
            Action action = () => { var service = new WebTestService(this._settings.Object, this._authContext.Object); };

            action.ShouldNotThrow <Exception>();
        }