//NOTE: Don't use IoC to avoid additional dependencies. private void InitializePresenters(bool isRunOnStartup) { NavigationWindow navigationWindow = new NavigationWindow(new PresentationService()); MainWindow = navigationWindow; IRegistryService registryService = new RegistryService(); ISettingsSerializer settingsSerializer = new SettingsSerializer(registryService); IPresenter navigationPresenter = new NavigationPresenter(navigationWindow, settingsSerializer, new KeyboardListener(), new MatchModelMapper(), new PresentationService(), new NavigationServiceBuilder(isRunOnStartup)); TrayView trayView = new TrayView(); IPresenter trayPresenter = new TrayIconPresenter(trayView, settingsSerializer); SettingsWindow settingsWindow = new SettingsWindow(); IPresenter settingsPresenter = new SettingsPresenter(settingsWindow, settingsSerializer); List <IPresenter> presenters = new List <IPresenter> { navigationPresenter, trayPresenter, settingsPresenter }; _presenterManager = new PresenterManager(presenters); _presenterManager.Exited += HandleExited; }
/// <summary> /// Initializes a new instance of the <see cref="TrayIconView"/> class. /// </summary> /// <param name="restingMonitor"> /// Dependency. Service that monitors the working and resting of users. /// </param> public TrayIconView(IRestingMonitor restingMonitor) { InitializeComponent(); var trayIconModel = new TrayIconModel(restingMonitor); components.Add(trayIconModel); #pragma warning disable CA2000 // Dispose objects before losing scope // TODO: inject Settings var trayIconPresenter = new TrayIconPresenter(Settings.Default, this, trayIconModel); components.Add(trayIconPresenter); #pragma warning restore CA2000 // Dispose objects before losing scope }
public void MonitorUpdated_CallShowBalloonOnlyIfUserIsntAway() { var configuration = Substitute.For <ITrayIconViewConfiguration>(); configuration.WarningInterval.Returns(TimeSpan.Zero); var iconView = Substitute.For <ITrayIconView>(); var model = Substitute.For <ITrayIconModel>(); model.MustRest.Returns(true); model.LastStatus.Returns(Models.UserStatus.Resting); using var sut = new TrayIconPresenter(configuration, iconView, model); // ACT Thread.Sleep(1); // make sure some time has been elapsed model.RestingMonitorUpdated += Raise.Event(); // ASSERT iconView.DidNotReceiveWithAnyArgs().ShowBalloonTip(0, null, null, Arg.Any <ToolTipIcon>()); }