public void MapCtrl_MethodsWithNoUserInteraction() { var focus = false; System.Threading.Thread t = new System.Threading.Thread(() => { MetaModel.MetaModel.Initialize(); var sut = new MainCtrl(); var form = new MainForm(); sut.InitMindMate(form, A.Fake <DialogManager>()); MainMenuCtrl mainMenuCtrl = new MainMenuCtrl(form.MainMenu, sut); form.MainMenuCtrl = mainMenuCtrl; form.Shown += (sender, args) => { sut.ReturnFocusToMapView(); sut.Bold(true); focus = sut.CurrentMapCtrl.MapView.Tree.RootNode.Bold; sut.ClearSelectionFormatting(); sut.Copy(); sut.Cut(); sut.Paste(); sut.SetBackColor(Color.White); sut.SetFontFamily("Arial"); sut.SetFontSize(15); sut.SetForeColor(Color.Blue); sut.SetMapViewBackColor(Color.White); sut.Strikethrough(true); sut.Subscript(); sut.Superscript(); sut.Underline(true); sut.PersistenceManager.NewTree(); sut.PersistenceManager.CloseCurerntTree(); }; Timer timer = new Timer { Interval = 5 }; //timer is used because the Dirty property is updated in the next event of GUI thread. timer.Tick += delegate { if (timer.Tag == null) { timer.Tag = "First Event Fired"; } else if (timer.Tag.Equals("First Event Fired")) { timer.Tag = "Second Event Fired"; } else { foreach (var f in sut.PersistenceManager) { f.IsDirty = false; //to avoid save warning dialog } form.Close(); } }; timer.Start(); form.ShowDialog(); timer.Stop(); }); t.SetApartmentState(System.Threading.ApartmentState.STA); t.Start(); t.Join(); Assert.IsTrue(focus); }