public void RegisterExceptionType_WhenTypeIsNotException_ThrowException() { Mock <IAlertDisplayer> alertDisplayerMock = new Mock <IAlertDisplayer>(); AppExceptionHandler handler = new AppExceptionHandler(alertDisplayerMock.Object); handler.RegisterExceptionType(typeof(int), "AnyMessage"); }
protected void InitializeShell(StartupEventArgs e) { _resetSplashCreated = new ManualResetEvent(false); _splashThread = new Thread(ShowSplash); _splashThread.SetApartmentState(ApartmentState.STA); _splashThread.IsBackground = true; _splashThread.Name = "Splash Screen"; _splashThread.Start(); _resetSplashCreated.WaitOne(); new Bootstrapper().Start(); base.OnStartup(e); _shellViewModel = MainWindow.DataContext as ShellViewModel; if (_shellViewModel != null) { CreateDummyWorkflowDesignerForCaching(); SplashView.CloseSplash(); CheckForDuplicateResources(); var settingsConfigFile = HelperUtils.GetStudioLogSettingsConfigFile(); if (!File.Exists(settingsConfigFile)) { File.WriteAllText(settingsConfigFile, GlobalConstants.DefaultStudioLogFileConfig); } Dev2Logger.AddEventLogging(settingsConfigFile, "Warewolf Studio"); XmlConfigurator.ConfigureAndWatch(new FileInfo(settingsConfigFile)); _appExceptionHandler = new AppExceptionHandler(this, _shellViewModel); } var toolboxPane = Current.MainWindow.FindName("Toolbox") as ContentPane; toolboxPane?.Activate(); }
public void RegisterExceptionType_WhenTypeIsException_RegisterException() { Mock <IAlertDisplayer> alertDisplayerMock = new Mock <IAlertDisplayer>(); AppExceptionHandler handler = new AppExceptionHandler(alertDisplayerMock.Object); handler.RegisterExceptionType(typeof(Exception), "AnyMessage"); Assert.AreEqual(1, handler.RegisteredExceptions.Count); handler.RegisterExceptionType(typeof(ArgumentException), "AnyMessage"); Assert.AreEqual(2, handler.RegisteredExceptions.Count); }
[PrincipalPermission(SecurityAction.Demand)] // Principal must be authenticated protected override void OnStartup(StartupEventArgs e) { Tracker.StartStudio(); bool createdNew; Task.Factory.StartNew(() => { var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "Warewolf", "Feedback"); DirectoryHelper.CleanUp(path); DirectoryHelper.CleanUp(Path.Combine(GlobalConstants.TempLocation, "Warewolf", "Debug")); }); // ReSharper disable once UnusedVariable var localprocessGuard = e.Args.Length > 0 ? new Mutex(true, e.Args[0], out createdNew) : new Mutex(true, "Warewolf Studio", out createdNew); if (createdNew) { _processGuard = localprocessGuard; } else { Environment.Exit(Environment.ExitCode); } Browser.Startup(); new Bootstrapper().Start(); base.OnStartup(e); var settingsConfigFile = HelperUtils.GetStudioLogSettingsConfigFile(); if (!File.Exists(settingsConfigFile)) { File.WriteAllText(settingsConfigFile, GlobalConstants.DefaultStudioLogFileConfig); } XmlConfigurator.ConfigureAndWatch(new FileInfo(settingsConfigFile)); _mainViewModel = MainWindow.DataContext as MainViewModel; //2013.07.01: Ashley Lewis for bug 9817 - setup exception handler on 'this', with main window data context as the popup dialog controller _appExceptionHandler = new AppExceptionHandler(this, _mainViewModel); #if !(DEBUG) var versionChecker = new VersionChecker(); if (versionChecker.GetNewerVersion()) { WebLatestVersionDialog dialog = new WebLatestVersionDialog(); dialog.ShowDialog(); } #endif }
public void Handle_WithNotRegisteredException_DisplayUnknownErrorAlert() { Mock <IAlertDisplayer> alertDisplayerMock = new Mock <IAlertDisplayer>(); alertDisplayerMock.Setup(alert => alert.DisplayAlert(this, It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>())) .Returns(It.IsAny <Task>()); AppExceptionHandler handler = new AppExceptionHandler(alertDisplayerMock.Object); handler.RegisterExceptionType(typeof(ArgumentException), "Ha ocurrido un problema registrado"); handler.HandleException(this, new Exception()); alertDisplayerMock.Verify(alert => alert.DisplayAlert(this, "Teacher Hiring App", "Ha ocurrido un problema desconocido", "Ok")); }
protected void InitializeShell(System.Windows.StartupEventArgs e) { _resetSplashCreated = new ManualResetEvent(false); _splashThread = new Thread(ShowSplash); _splashThread.SetApartmentState(ApartmentState.STA); _splashThread.IsBackground = true; _splashThread.Name = "Splash Screen"; _splashThread.Start(); _resetSplashCreated.WaitOne(); new Bootstrapper().Start(); if (_hasDotNetFramweworkError) { SplashView.CloseSplash(false); var popupController = CustomContainer.Get <IPopupController>(); popupController.ShowInstallationErrorOccurred(); Shutdown(); } base.OnStartup(e); _shellViewModel = MainWindow.DataContext as ShellViewModel; if (_shellViewModel != null) { CreateDummyWorkflowDesignerForCaching(); SplashView.CloseSplash(false); if (e.Args.Length > 0) { OpenBasedOnArguments(new WarwolfStartupEventArgs(e)); } else { _shellViewModel.ShowStartPageAsync(); } CheckForDuplicateResources(); _appExceptionHandler = new AppExceptionHandler(this, _shellViewModel); CustomContainer.Register <IApplicationAdaptor>(new ApplicationAdaptor(Current)); CustomContainer.Register <IShellViewModel>(_shellViewModel); } var toolboxPane = Current.MainWindow.FindName("Toolbox") as ContentPane; toolboxPane?.Activate(); #if DEBUG SetAsStarted(); }