Exemple #1
0
        public void ShouldNotifySubscribers()
        {
            MemoryLogger          logger;
            TaskCallbackService   module;
            MockedCallback        callback;
            MockedSchedulerModule mockedSchedulerModule;

            logger = new MemoryLogger();

            mockedSchedulerModule = new MockedSchedulerModule(false);
            callback = new MockedCallback(false);
            module   = new TaskCallbackService(logger, mockedSchedulerModule);
            Assert.IsTrue(module.Subscribe(callback));

            Assert.AreEqual(0, callback.StartedCount);
            mockedSchedulerModule.InvokeTaskStarted();
            Assert.AreEqual(1, callback.StartedCount);

            Assert.AreEqual(0, callback.EndedCount);
            mockedSchedulerModule.InvokeTaskEnded();
            Assert.AreEqual(1, callback.EndedCount);
        }
Exemple #2
0
        public void ShouldNNotNotifySubscribersAndLogError()
        {
            MemoryLogger          logger;
            TaskCallbackService   module;
            MockedCallback        callback;
            MockedSchedulerModule mockedSchedulerModule;

            logger = new MemoryLogger();

            mockedSchedulerModule = new MockedSchedulerModule(false);
            callback = new MockedCallback(true);
            module   = new TaskCallbackService(logger, mockedSchedulerModule);
            Assert.IsTrue(module.Subscribe(callback));

            Assert.AreEqual(0, callback.StartedCount);
            mockedSchedulerModule.InvokeTaskStarted();
            Assert.AreEqual(0, callback.StartedCount);
            Assert.IsNotNull(logger.Logs.FirstOrDefault(item => (item.Level == LogLevels.Warning) && (item.ComponentName == module.ModuleName)));

            Assert.AreEqual(0, callback.EndedCount);
            mockedSchedulerModule.InvokeTaskEnded();
            Assert.AreEqual(0, callback.EndedCount);
            Assert.IsNotNull(logger.Logs.FirstOrDefault(item => (item.Level == LogLevels.Warning) && (item.ComponentName == module.ModuleName)));
        }