public void TestLimitDisabled()
        {
            var xmlSettings = new UserSettingsService();

            xmlSettings.Initialize();

            var logger          = new Mock <ILogger>();
            var mediator        = new Mock <Mediator>();
            var shutdownService = new Mock <IShutdownService>();

            var limitHandler = new LimitHandler(mediator.Object, xmlSettings, logger.Object, shutdownService.Object);
            var app          = new Aplication()
            {
                WinName = "test app"
            };
            var limit = new AppLimit()
            {
                LimitReachedAction = LimitReachedAction.Warn, Application = app, ID = 1
            };

            xmlSettings.LimitsSettings.DontShowLimits.Add(limit.ID);

            limitHandler.Handle(limit);
            mediator.Verify(m => m.NotifyColleagues(MediatorMessages.APP_LIMIT_REACHED, limit), Times.Never());
        }
Beispiel #2
0
        public void TestInitialize()
        {
            var settingsService = new UserSettingsService();

            settingsService.Initialize();

            Assert.IsNotNull(settingsService.AppSettings);
            Assert.IsNotNull(settingsService.DaysViewSettings);
            Assert.IsNotNull(settingsService.LimitsSettings);
            Assert.IsNotNull(settingsService.LogsViewSettings);
            Assert.IsNotNull(settingsService.MainWindowSettings);
            Assert.IsNotNull(settingsService.ScreenshotsViewSettings);
        }
        public void TestShutdownAndWarn()
        {
            var xmlSettings = new UserSettingsService();

            xmlSettings.Initialize();

            var logger          = new Mock <ILogger>();
            var mediator        = new Mock <Mediator>();
            var shutdownService = new Mock <IShutdownService>();

            var limitHandler = new LimitHandler(mediator.Object, xmlSettings, logger.Object, shutdownService.Object);
            var app          = new Aplication()
            {
                WinName = "test app"
            };
            var limit = new AppLimit()
            {
                LimitReachedAction = LimitReachedAction.WarnAndShutdown, Application = app
            };

            limitHandler.Handle(limit);
            mediator.Verify(m => m.NotifyColleagues(MediatorMessages.APP_LIMIT_REACHED, limit), Times.Once());
            shutdownService.Verify(s => s.Shutdown(app.WinName), Times.Once());
        }